Rev 3283 Rev 3286
1 CCS PCM C Compiler, Version 4.106, 47914 03-IX-13 00:32 1 CCS PCM C Compiler, Version 4.106, 47914 10-IX-13 13:59
2   2  
3 Filename: D:\MLAB\Designs\Measuring_instruments\GeoMet01A\SW\PIC16F887\main.lst 3 Filename: Z:\home\kaklik\svnMLAB\Designs\Measuring_instruments\GeoMet01A\SW\PIC16F887\main.lst
4   4  
5 ROM used: 3183 words (39%) 5 ROM used: 3809 words (46%)
6 Largest free fragment is 2048 6 Largest free fragment is 2048
7 RAM used: 27 (7%) at main() level 7 RAM used: 35 (10%) at main() level
8 52 (14%) worst case 8 72 (20%) worst case
9 Stack: 5 locations 9 Stack: 5 locations
10   10  
11 * 11 *
12 0000: MOVLW 0A 12 0000: MOVLW 0C
13 0001: MOVWF 0A 13 0001: MOVWF 0A
14 0002: GOTO 2B7 14 0002: GOTO 4E5
15 0003: NOP 15 0003: NOP
16 .................... #include "main.h" 16 .................... #include "main.h"
17 .................... #include <16F887.h> 17 .................... #include <16F887.h>
18 .................... //////// Standard Header file for the PIC16F887 device //////////////// 18 .................... //////// Standard Header file for the PIC16F887 device ////////////////
19 .................... #device PIC16F887 19 .................... #device PIC16F887
20 .................... #list 20 .................... #list
21 .................... 21 ....................
22 .................... #device adc=10 22 .................... #device adc=10
23 .................... 23 ....................
24 .................... #FUSES NOWDT //No Watch Dog Timer 24 .................... #FUSES NOWDT //No Watch Dog Timer
25 .................... #FUSES INTRC //Internal RC Osc 25 .................... #FUSES INTRC //Internal RC Osc
26 .................... #FUSES NOPUT //No Power Up Timer 26 .................... #FUSES NOPUT //No Power Up Timer
27 .................... #FUSES MCLR //Master Clear pin enabled 27 .................... #FUSES MCLR //Master Clear pin enabled
28 .................... #FUSES NOPROTECT //Code not protected from reading 28 .................... #FUSES NOPROTECT //Code not protected from reading
29 .................... #FUSES NOCPD //No EE protection 29 .................... #FUSES NOCPD //No EE protection
30 .................... #FUSES NOBROWNOUT //No brownout reset 30 .................... #FUSES NOBROWNOUT //No brownout reset
31 .................... #FUSES IESO //Internal External Switch Over mode enabled 31 .................... #FUSES IESO //Internal External Switch Over mode enabled
32 .................... #FUSES FCMEN //Fail-safe clock monitor enabled 32 .................... #FUSES FCMEN //Fail-safe clock monitor enabled
33 .................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O 33 .................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
34 .................... #FUSES NODEBUG //No Debug mode for ICD 34 .................... #FUSES NODEBUG //No Debug mode for ICD
35 .................... #FUSES NOWRT //Program memory not write protected 35 .................... #FUSES NOWRT //Program memory not write protected
36 .................... #FUSES BORV40 //Brownout reset at 4.0V 36 .................... #FUSES BORV40 //Brownout reset at 4.0V
37 .................... 37 ....................
38 .................... #use delay(clock=8000000) 38 .................... #use delay(clock=8000000)
39 * 39 *
40 00FB: MOVLW 43 40 00FB: MOVLW 4B
41 00FC: MOVWF 04 41 00FC: MOVWF 04
42 00FD: BCF 03.7 42 00FD: BCF 03.7
43 00FE: MOVF 00,W 43 00FE: MOVF 00,W
44 00FF: BTFSC 03.2 44 00FF: BTFSC 03.2
45 0100: GOTO 10E 45 0100: GOTO 10E
46 0101: MOVLW 02 46 0101: MOVLW 02
47 0102: MOVWF 78 47 0102: MOVWF 78
48 0103: CLRF 77 48 0103: CLRF 77
49 0104: DECFSZ 77,F 49 0104: DECFSZ 77,F
50 0105: GOTO 104 50 0105: GOTO 104
51 0106: DECFSZ 78,F 51 0106: DECFSZ 78,F
52 0107: GOTO 103 52 0107: GOTO 103
53 0108: MOVLW 97 53 0108: MOVLW 97
54 0109: MOVWF 77 54 0109: MOVWF 77
55 010A: DECFSZ 77,F 55 010A: DECFSZ 77,F
56 010B: GOTO 10A 56 010B: GOTO 10A
57 010C: DECFSZ 00,F 57 010C: DECFSZ 00,F
58 010D: GOTO 101 58 010D: GOTO 101
59 010E: RETURN 59 010E: RETURN
60 .................... #use i2c(master, sda=PIN_C4, scl=PIN_C3) 60 .................... #use i2c(master, sda=PIN_C4, scl=PIN_C3)
61 * 61 *
62 0078: MOVLW 08 62 0078: MOVLW 08
63 0079: MOVWF 78 63 0079: MOVWF 78
64 007A: NOP 64 007A: NOP
65 007B: BCF 07.3 65 007B: BCF 07.3
66 007C: BCF 20.3 66 007C: BCF 20.3
67 007D: MOVF 20,W 67 007D: MOVF 20,W
68 007E: BSF 03.5 68 007E: BSF 03.5
69 007F: MOVWF 07 69 007F: MOVWF 07
70 0080: NOP 70 0080: NOP
71 0081: BCF 03.5 71 0081: BCF 03.5
72 0082: RLF 3B,F 72 0082: RLF 4E,F
73 0083: BCF 07.4 73 0083: BCF 07.4
74 0084: BTFSS 03.0 74 0084: BTFSS 03.0
75 0085: GOTO 08C 75 0085: GOTO 08C
76 0086: BSF 20.4 76 0086: BSF 20.4
77 0087: MOVF 20,W 77 0087: MOVF 20,W
78 0088: BSF 03.5 78 0088: BSF 03.5
79 0089: MOVWF 07 79 0089: MOVWF 07
80 008A: GOTO 090 80 008A: GOTO 090
81 008B: BCF 03.5 81 008B: BCF 03.5
82 008C: BCF 20.4 82 008C: BCF 20.4
83 008D: MOVF 20,W 83 008D: MOVF 20,W
84 008E: BSF 03.5 84 008E: BSF 03.5
85 008F: MOVWF 07 85 008F: MOVWF 07
86 0090: NOP 86 0090: NOP
87 0091: BCF 03.5 87 0091: BCF 03.5
88 0092: BSF 20.3 88 0092: BSF 20.3
89 0093: MOVF 20,W 89 0093: MOVF 20,W
90 0094: BSF 03.5 90 0094: BSF 03.5
91 0095: MOVWF 07 91 0095: MOVWF 07
92 0096: BCF 03.5 92 0096: BCF 03.5
93 0097: BTFSS 07.3 93 0097: BTFSS 07.3
94 0098: GOTO 097 94 0098: GOTO 097
95 0099: DECFSZ 78,F 95 0099: DECFSZ 78,F
96 009A: GOTO 07A 96 009A: GOTO 07A
97 009B: NOP 97 009B: NOP
98 009C: BCF 07.3 98 009C: BCF 07.3
99 009D: BCF 20.3 99 009D: BCF 20.3
100 009E: MOVF 20,W 100 009E: MOVF 20,W
101 009F: BSF 03.5 101 009F: BSF 03.5
102 00A0: MOVWF 07 102 00A0: MOVWF 07
103 00A1: NOP 103 00A1: NOP
104 00A2: BCF 03.5 104 00A2: BCF 03.5
105 00A3: BSF 20.4 105 00A3: BSF 20.4
106 00A4: MOVF 20,W 106 00A4: MOVF 20,W
107 00A5: BSF 03.5 107 00A5: BSF 03.5
108 00A6: MOVWF 07 108 00A6: MOVWF 07
109 00A7: NOP 109 00A7: NOP
110 00A8: NOP 110 00A8: NOP
111 00A9: BCF 03.5 111 00A9: BCF 03.5
112 00AA: BSF 20.3 112 00AA: BSF 20.3
113 00AB: MOVF 20,W 113 00AB: MOVF 20,W
114 00AC: BSF 03.5 114 00AC: BSF 03.5
115 00AD: MOVWF 07 115 00AD: MOVWF 07
116 00AE: BCF 03.5 116 00AE: BCF 03.5
117 00AF: BTFSS 07.3 117 00AF: BTFSS 07.3
118 00B0: GOTO 0AF 118 00B0: GOTO 0AF
119 00B1: CLRF 78 119 00B1: CLRF 78
120 00B2: NOP 120 00B2: NOP
121 00B3: BTFSC 07.4 121 00B3: BTFSC 07.4
122 00B4: BSF 78.0 122 00B4: BSF 78.0
123 00B5: BCF 07.3 123 00B5: BCF 07.3
124 00B6: BCF 20.3 124 00B6: BCF 20.3
125 00B7: MOVF 20,W 125 00B7: MOVF 20,W
126 00B8: BSF 03.5 126 00B8: BSF 03.5
127 00B9: MOVWF 07 127 00B9: MOVWF 07
128 00BA: BCF 03.5 128 00BA: BCF 03.5
129 00BB: BCF 07.4 129 00BB: BCF 07.4
130 00BC: BCF 20.4 130 00BC: BCF 20.4
131 00BD: MOVF 20,W 131 00BD: MOVF 20,W
132 00BE: BSF 03.5 132 00BE: BSF 03.5
133 00BF: MOVWF 07 133 00BF: MOVWF 07
134 00C0: BCF 03.5 134 00C0: BCF 03.5
135 00C1: RETURN 135 00C1: RETURN
136 * 136 *
137 0285: MOVLW 08 137 0285: MOVLW 08
138 0286: MOVWF 3C 138 0286: MOVWF 4F
139 0287: MOVF 77,W 139 0287: MOVF 77,W
140 0288: MOVWF 3D 140 0288: MOVWF 50
141 0289: BSF 20.4 141 0289: BSF 20.4
142 028A: MOVF 20,W 142 028A: MOVF 20,W
143 028B: BSF 03.5 143 028B: BSF 03.5
144 028C: MOVWF 07 144 028C: MOVWF 07
145 028D: NOP 145 028D: NOP
146 028E: BCF 03.5 146 028E: BCF 03.5
147 028F: BSF 20.3 147 028F: BSF 20.3
148 0290: MOVF 20,W 148 0290: MOVF 20,W
149 0291: BSF 03.5 149 0291: BSF 03.5
150 0292: MOVWF 07 150 0292: MOVWF 07
151 0293: BCF 03.5 151 0293: BCF 03.5
152 0294: BTFSS 07.3 152 0294: BTFSS 07.3
153 0295: GOTO 294 153 0295: GOTO 294
154 0296: BTFSC 07.4 154 0296: BTFSC 07.4
155 0297: BSF 03.0 155 0297: BSF 03.0
156 0298: BTFSS 07.4 156 0298: BTFSS 07.4
157 0299: BCF 03.0 157 0299: BCF 03.0
158 029A: RLF 78,F 158 029A: RLF 78,F
159 029B: NOP 159 029B: NOP
160 029C: BCF 20.3 160 029C: BCF 20.3
161 029D: MOVF 20,W 161 029D: MOVF 20,W
162 029E: BSF 03.5 162 029E: BSF 03.5
163 029F: MOVWF 07 163 029F: MOVWF 07
164 02A0: BCF 03.5 164 02A0: BCF 03.5
165 02A1: BCF 07.3 165 02A1: BCF 07.3
166 02A2: DECFSZ 3C,F 166 02A2: DECFSZ 4F,F
167 02A3: GOTO 289 167 02A3: GOTO 289
168 02A4: BSF 20.4 168 02A4: BSF 20.4
169 02A5: MOVF 20,W 169 02A5: MOVF 20,W
170 02A6: BSF 03.5 170 02A6: BSF 03.5
171 02A7: MOVWF 07 171 02A7: MOVWF 07
172 02A8: NOP 172 02A8: NOP
173 02A9: BCF 03.5 173 02A9: BCF 03.5
174 02AA: BCF 07.4 174 02AA: BCF 07.4
175 02AB: MOVF 3D,W 175 02AB: MOVF 50,W
176 02AC: BTFSC 03.2 176 02AC: BTFSC 03.2
177 02AD: GOTO 2B3 177 02AD: GOTO 2B3
178 02AE: BCF 20.4 178 02AE: BCF 20.4
179 02AF: MOVF 20,W 179 02AF: MOVF 20,W
180 02B0: BSF 03.5 180 02B0: BSF 03.5
181 02B1: MOVWF 07 181 02B1: MOVWF 07
182 02B2: BCF 03.5 182 02B2: BCF 03.5
183 02B3: NOP 183 02B3: NOP
184 02B4: BSF 20.3 184 02B4: BSF 20.3
185 02B5: MOVF 20,W 185 02B5: MOVF 20,W
186 02B6: BSF 03.5 186 02B6: BSF 03.5
187 02B7: MOVWF 07 187 02B7: MOVWF 07
188 02B8: BCF 03.5 188 02B8: BCF 03.5
189 02B9: BTFSS 07.3 189 02B9: BTFSS 07.3
190 02BA: GOTO 2B9 190 02BA: GOTO 2B9
191 02BB: NOP 191 02BB: NOP
192 02BC: BCF 07.3 192 02BC: BCF 07.3
193 02BD: BCF 20.3 193 02BD: BCF 20.3
194 02BE: MOVF 20,W 194 02BE: MOVF 20,W
195 02BF: BSF 03.5 195 02BF: BSF 03.5
196 02C0: MOVWF 07 196 02C0: MOVWF 07
197 02C1: NOP 197 02C1: NOP
198 02C2: BCF 03.5 198 02C2: BCF 03.5
199 02C3: BCF 07.4 199 02C3: BCF 07.4
200 02C4: BCF 20.4 200 02C4: BCF 20.4
201 02C5: MOVF 20,W 201 02C5: MOVF 20,W
202 02C6: BSF 03.5 202 02C6: BSF 03.5
203 02C7: MOVWF 07 203 02C7: MOVWF 07
204 02C8: BCF 03.5 204 02C8: BCF 03.5
205 02C9: RETURN 205 02C9: RETURN
206 .................... #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8) 206 .................... #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
207 .................... 207 ....................
208 .................... 208 ....................
209 .................... 209 ....................
210 .................... #define LCD_ENABLE_PIN PIN_E0 //// 210 .................... #define LCD_ENABLE_PIN PIN_E0 ////
211 .................... #define LCD_RS_PIN PIN_E1 //// 211 .................... #define LCD_RS_PIN PIN_E1 ////
212 .................... #define LCD_RW_PIN PIN_E2 //// 212 .................... #define LCD_RW_PIN PIN_E2 ////
213 .................... #define LCD_DATA4 PIN_D4 //// 213 .................... #define LCD_DATA4 PIN_D4 ////
214 .................... #define LCD_DATA5 PIN_D5 //// 214 .................... #define LCD_DATA5 PIN_D5 ////
215 .................... #define LCD_DATA6 PIN_D6 //// 215 .................... #define LCD_DATA6 PIN_D6 ////
216 .................... #define LCD_DATA7 PIN_D7 216 .................... #define LCD_DATA7 PIN_D7
217 .................... #include <lcd.c> 217 .................... #include <lcd.c>
218 .................... /////////////////////////////////////////////////////////////////////////////// 218 .................... ///////////////////////////////////////////////////////////////////////////////
219 .................... //// LCD.C //// 219 .................... //// LCD.C ////
220 .................... //// Driver for common LCD modules //// 220 .................... //// Driver for common LCD modules ////
221 .................... //// //// 221 .................... //// ////
222 .................... //// lcd_init() Must be called before any other function. //// 222 .................... //// lcd_init() Must be called before any other function. ////
223 .................... //// //// 223 .................... //// ////
224 .................... //// lcd_putc(c) Will display c on the next position of the LCD. //// 224 .................... //// lcd_putc(c) Will display c on the next position of the LCD. ////
225 .................... //// \a Set cursor position to upper left //// 225 .................... //// \a Set cursor position to upper left ////
226 .................... //// \f Clear display, set cursor to upper left //// 226 .................... //// \f Clear display, set cursor to upper left ////
227 .................... //// \n Go to start of second line //// 227 .................... //// \n Go to start of second line ////
228 .................... //// \b Move back one position //// 228 .................... //// \b Move back one position ////
229 .................... //// If LCD_EXTENDED_NEWLINE is defined, the \n character //// 229 .................... //// If LCD_EXTENDED_NEWLINE is defined, the \n character ////
230 .................... //// will erase all remanining characters on the current //// 230 .................... //// will erase all remanining characters on the current ////
231 .................... //// line, and move the cursor to the beginning of the next //// 231 .................... //// line, and move the cursor to the beginning of the next ////
232 .................... //// line. //// 232 .................... //// line. ////
233 .................... //// If LCD_EXTENDED_NEWLINE is defined, the \r character //// 233 .................... //// If LCD_EXTENDED_NEWLINE is defined, the \r character ////
234 .................... //// will move the cursor to the start of the current //// 234 .................... //// will move the cursor to the start of the current ////
235 .................... //// line. //// 235 .................... //// line. ////
236 .................... //// //// 236 .................... //// ////
237 .................... //// lcd_gotoxy(x,y) Set write position on LCD (upper left is 1,1) //// 237 .................... //// lcd_gotoxy(x,y) Set write position on LCD (upper left is 1,1) ////
238 .................... //// //// 238 .................... //// ////
239 .................... //// lcd_getc(x,y) Returns character at position x,y on LCD //// 239 .................... //// lcd_getc(x,y) Returns character at position x,y on LCD ////
240 .................... //// //// 240 .................... //// ////
241 .................... //// CONFIGURATION //// 241 .................... //// CONFIGURATION ////
242 .................... //// The LCD can be configured in one of two ways: a.) port access or //// 242 .................... //// The LCD can be configured in one of two ways: a.) port access or ////
243 .................... //// b.) pin access. Port access requires the entire 7 bit interface //// 243 .................... //// b.) pin access. Port access requires the entire 7 bit interface ////
244 .................... //// connected to one GPIO port, and the data bits (D4:D7 of the LCD) //// 244 .................... //// connected to one GPIO port, and the data bits (D4:D7 of the LCD) ////
245 .................... //// connected to sequential pins on the GPIO. Pin access //// 245 .................... //// connected to sequential pins on the GPIO. Pin access ////
246 .................... //// has no requirements, all 7 bits of the control interface can //// 246 .................... //// has no requirements, all 7 bits of the control interface can ////
247 .................... //// can be connected to any GPIO using several ports. //// 247 .................... //// can be connected to any GPIO using several ports. ////
248 .................... //// //// 248 .................... //// ////
249 .................... //// To use port access, #define LCD_DATA_PORT to the SFR location of //// 249 .................... //// To use port access, #define LCD_DATA_PORT to the SFR location of ////
250 .................... //// of the GPIO port that holds the interface, -AND- edit LCD_PIN_MAP //// 250 .................... //// of the GPIO port that holds the interface, -AND- edit LCD_PIN_MAP ////
251 .................... //// of this file to configure the pin order. If you are using a //// 251 .................... //// of this file to configure the pin order. If you are using a ////
252 .................... //// baseline PIC (PCB), then LCD_OUTPUT_MAP and LCD_INPUT_MAP also must //// 252 .................... //// baseline PIC (PCB), then LCD_OUTPUT_MAP and LCD_INPUT_MAP also must ////
253 .................... //// be defined. //// 253 .................... //// be defined. ////
254 .................... //// //// 254 .................... //// ////
255 .................... //// Example of port access: //// 255 .................... //// Example of port access: ////
256 .................... //// #define LCD_DATA_PORT getenv("SFR:PORTD") //// 256 .................... //// #define LCD_DATA_PORT getenv("SFR:PORTD") ////
257 .................... //// //// 257 .................... //// ////
258 .................... //// To use pin access, the following pins must be defined: //// 258 .................... //// To use pin access, the following pins must be defined: ////
259 .................... //// LCD_ENABLE_PIN //// 259 .................... //// LCD_ENABLE_PIN ////
260 .................... //// LCD_RS_PIN //// 260 .................... //// LCD_RS_PIN ////
261 .................... //// LCD_RW_PIN //// 261 .................... //// LCD_RW_PIN ////
262 .................... //// LCD_DATA4 //// 262 .................... //// LCD_DATA4 ////
263 .................... //// LCD_DATA5 //// 263 .................... //// LCD_DATA5 ////
264 .................... //// LCD_DATA6 //// 264 .................... //// LCD_DATA6 ////
265 .................... //// LCD_DATA7 //// 265 .................... //// LCD_DATA7 ////
266 .................... //// //// 266 .................... //// ////
267 .................... //// Example of pin access: //// 267 .................... //// Example of pin access: ////
268 .................... //// #define LCD_ENABLE_PIN PIN_E0 //// 268 .................... //// #define LCD_ENABLE_PIN PIN_E0 ////
269 .................... //// #define LCD_RS_PIN PIN_E1 //// 269 .................... //// #define LCD_RS_PIN PIN_E1 ////
270 .................... //// #define LCD_RW_PIN PIN_E2 //// 270 .................... //// #define LCD_RW_PIN PIN_E2 ////
271 .................... //// #define LCD_DATA4 PIN_D4 //// 271 .................... //// #define LCD_DATA4 PIN_D4 ////
272 .................... //// #define LCD_DATA5 PIN_D5 //// 272 .................... //// #define LCD_DATA5 PIN_D5 ////
273 .................... //// #define LCD_DATA6 PIN_D6 //// 273 .................... //// #define LCD_DATA6 PIN_D6 ////
274 .................... //// #define LCD_DATA7 PIN_D7 //// 274 .................... //// #define LCD_DATA7 PIN_D7 ////
275 .................... //// //// 275 .................... //// ////
276 .................... /////////////////////////////////////////////////////////////////////////////// 276 .................... ///////////////////////////////////////////////////////////////////////////////
277 .................... //// (C) Copyright 1996,2010 Custom Computer Services //// 277 .................... //// (C) Copyright 1996,2010 Custom Computer Services ////
278 .................... //// This source code may only be used by licensed users of the CCS C //// 278 .................... //// This source code may only be used by licensed users of the CCS C ////
279 .................... //// compiler. This source code may only be distributed to other //// 279 .................... //// compiler. This source code may only be distributed to other ////
280 .................... //// licensed users of the CCS C compiler. No other use, reproduction //// 280 .................... //// licensed users of the CCS C compiler. No other use, reproduction ////
281 .................... //// or distribution is permitted without written permission. //// 281 .................... //// or distribution is permitted without written permission. ////
282 .................... //// Derivative programs created using this software in object code //// 282 .................... //// Derivative programs created using this software in object code ////
283 .................... //// form are not restricted in any way. //// 283 .................... //// form are not restricted in any way. ////
284 .................... /////////////////////////////////////////////////////////////////////////// 284 .................... ///////////////////////////////////////////////////////////////////////////
285 .................... 285 ....................
286 .................... // define the pinout. 286 .................... // define the pinout.
287 .................... // only required if port access is being used. 287 .................... // only required if port access is being used.
288 .................... typedef struct 288 .................... typedef struct
289 .................... { // This structure is overlayed 289 .................... { // This structure is overlayed
290 .................... BOOLEAN enable; // on to an I/O port to gain 290 .................... BOOLEAN enable; // on to an I/O port to gain
291 .................... BOOLEAN rs; // access to the LCD pins. 291 .................... BOOLEAN rs; // access to the LCD pins.
292 .................... BOOLEAN rw; // The bits are allocated from 292 .................... BOOLEAN rw; // The bits are allocated from
293 .................... BOOLEAN unused; // low order up. ENABLE will 293 .................... BOOLEAN unused; // low order up. ENABLE will
294 .................... int data : 4; // be LSB pin of that port. 294 .................... int data : 4; // be LSB pin of that port.
295 .................... #if defined(__PCD__) // The port used will be LCD_DATA_PORT. 295 .................... #if defined(__PCD__) // The port used will be LCD_DATA_PORT.
296 .................... int reserved: 8; 296 .................... int reserved: 8;
297 .................... #endif 297 .................... #endif
298 .................... } LCD_PIN_MAP; 298 .................... } LCD_PIN_MAP;
299 .................... 299 ....................
300 .................... // this is to improve compatability with previous LCD drivers that accepted 300 .................... // this is to improve compatability with previous LCD drivers that accepted
301 .................... // a define labeled 'use_portb_lcd' that configured the LCD onto port B. 301 .................... // a define labeled 'use_portb_lcd' that configured the LCD onto port B.
302 .................... #if ((defined(use_portb_lcd)) && (use_portb_lcd==TRUE)) 302 .................... #if ((defined(use_portb_lcd)) && (use_portb_lcd==TRUE))
303 .................... #define LCD_DATA_PORT getenv("SFR:PORTB") 303 .................... #define LCD_DATA_PORT getenv("SFR:PORTB")
304 .................... #endif 304 .................... #endif
305 .................... 305 ....................
306 .................... #if defined(__PCB__) 306 .................... #if defined(__PCB__)
307 .................... // these definitions only need to be modified for baseline PICs. 307 .................... // these definitions only need to be modified for baseline PICs.
308 .................... // all other PICs use LCD_PIN_MAP or individual LCD_xxx pin definitions. 308 .................... // all other PICs use LCD_PIN_MAP or individual LCD_xxx pin definitions.
309 .................... /* EN, RS, RW, UNUSED, DATA */ 309 .................... /* EN, RS, RW, UNUSED, DATA */
310 .................... const LCD_PIN_MAP LCD_OUTPUT_MAP = {0, 0, 0, 0, 0}; 310 .................... const LCD_PIN_MAP LCD_OUTPUT_MAP = {0, 0, 0, 0, 0};
311 .................... const LCD_PIN_MAP LCD_INPUT_MAP = {0, 0, 0, 0, 0xF}; 311 .................... const LCD_PIN_MAP LCD_INPUT_MAP = {0, 0, 0, 0, 0xF};
312 .................... #endif 312 .................... #endif
313 .................... 313 ....................
314 .................... ////////////////////// END CONFIGURATION /////////////////////////////////// 314 .................... ////////////////////// END CONFIGURATION ///////////////////////////////////
315 .................... 315 ....................
316 .................... #ifndef LCD_ENABLE_PIN 316 .................... #ifndef LCD_ENABLE_PIN
317 .................... #define lcd_output_enable(x) lcdlat.enable=x 317 .................... #define lcd_output_enable(x) lcdlat.enable=x
318 .................... #define lcd_enable_tris() lcdtris.enable=0 318 .................... #define lcd_enable_tris() lcdtris.enable=0
319 .................... #else 319 .................... #else
320 .................... #define lcd_output_enable(x) output_bit(LCD_ENABLE_PIN, x) 320 .................... #define lcd_output_enable(x) output_bit(LCD_ENABLE_PIN, x)
321 .................... #define lcd_enable_tris() output_drive(LCD_ENABLE_PIN) 321 .................... #define lcd_enable_tris() output_drive(LCD_ENABLE_PIN)
322 .................... #endif 322 .................... #endif
323 .................... 323 ....................
324 .................... #ifndef LCD_RS_PIN 324 .................... #ifndef LCD_RS_PIN
325 .................... #define lcd_output_rs(x) lcdlat.rs=x 325 .................... #define lcd_output_rs(x) lcdlat.rs=x
326 .................... #define lcd_rs_tris() lcdtris.rs=0 326 .................... #define lcd_rs_tris() lcdtris.rs=0
327 .................... #else 327 .................... #else
328 .................... #define lcd_output_rs(x) output_bit(LCD_RS_PIN, x) 328 .................... #define lcd_output_rs(x) output_bit(LCD_RS_PIN, x)
329 .................... #define lcd_rs_tris() output_drive(LCD_RS_PIN) 329 .................... #define lcd_rs_tris() output_drive(LCD_RS_PIN)
330 .................... #endif 330 .................... #endif
331 .................... 331 ....................
332 .................... #ifndef LCD_RW_PIN 332 .................... #ifndef LCD_RW_PIN
333 .................... #define lcd_output_rw(x) lcdlat.rw=x 333 .................... #define lcd_output_rw(x) lcdlat.rw=x
334 .................... #define lcd_rw_tris() lcdtris.rw=0 334 .................... #define lcd_rw_tris() lcdtris.rw=0
335 .................... #else 335 .................... #else
336 .................... #define lcd_output_rw(x) output_bit(LCD_RW_PIN, x) 336 .................... #define lcd_output_rw(x) output_bit(LCD_RW_PIN, x)
337 .................... #define lcd_rw_tris() output_drive(LCD_RW_PIN) 337 .................... #define lcd_rw_tris() output_drive(LCD_RW_PIN)
338 .................... #endif 338 .................... #endif
339 .................... 339 ....................
340 .................... // original version of this library incorrectly labeled LCD_DATA0 as LCD_DATA4, 340 .................... // original version of this library incorrectly labeled LCD_DATA0 as LCD_DATA4,
341 .................... // LCD_DATA1 as LCD_DATA5, and so on. this block of code makes the driver 341 .................... // LCD_DATA1 as LCD_DATA5, and so on. this block of code makes the driver
342 .................... // compatible with any code written for the original library 342 .................... // compatible with any code written for the original library
343 .................... #if (defined(LCD_DATA0) && defined(LCD_DATA1) && defined(LCD_DATA2) && defined(LCD_DATA3) && !defined(LCD_DATA4) && !defined(LCD_DATA5) && !defined(LCD_DATA6) && !defined(LCD_DATA7)) 343 .................... #if (defined(LCD_DATA0) && defined(LCD_DATA1) && defined(LCD_DATA2) && defined(LCD_DATA3) && !defined(LCD_DATA4) && !defined(LCD_DATA5) && !defined(LCD_DATA6) && !defined(LCD_DATA7))
344 .................... #define LCD_DATA4 LCD_DATA0 344 .................... #define LCD_DATA4 LCD_DATA0
345 .................... #define LCD_DATA5 LCD_DATA1 345 .................... #define LCD_DATA5 LCD_DATA1
346 .................... #define LCD_DATA6 LCD_DATA2 346 .................... #define LCD_DATA6 LCD_DATA2
347 .................... #define LCD_DATA7 LCD_DATA3 347 .................... #define LCD_DATA7 LCD_DATA3
348 .................... #endif 348 .................... #endif
349 .................... 349 ....................
350 .................... #ifndef LCD_DATA4 350 .................... #ifndef LCD_DATA4
351 .................... #ifndef LCD_DATA_PORT 351 .................... #ifndef LCD_DATA_PORT
352 .................... #if defined(__PCB__) 352 .................... #if defined(__PCB__)
353 .................... #define LCD_DATA_PORT 0x06 //portb 353 .................... #define LCD_DATA_PORT 0x06 //portb
354 .................... #define set_tris_lcd(x) set_tris_b(x) 354 .................... #define set_tris_lcd(x) set_tris_b(x)
355 .................... #else 355 .................... #else
356 .................... #if defined(PIN_D0) 356 .................... #if defined(PIN_D0)
357 .................... #define LCD_DATA_PORT getenv("SFR:PORTD") //portd 357 .................... #define LCD_DATA_PORT getenv("SFR:PORTD") //portd
358 .................... #else 358 .................... #else
359 .................... #define LCD_DATA_PORT getenv("SFR:PORTB") //portb 359 .................... #define LCD_DATA_PORT getenv("SFR:PORTB") //portb
360 .................... #endif 360 .................... #endif
361 .................... #endif 361 .................... #endif
362 .................... #endif 362 .................... #endif
363 .................... 363 ....................
364 .................... #if defined(__PCB__) 364 .................... #if defined(__PCB__)
365 .................... LCD_PIN_MAP lcd, lcdlat; 365 .................... LCD_PIN_MAP lcd, lcdlat;
366 .................... #byte lcd = LCD_DATA_PORT 366 .................... #byte lcd = LCD_DATA_PORT
367 .................... #byte lcdlat = LCD_DATA_PORT 367 .................... #byte lcdlat = LCD_DATA_PORT
368 .................... #elif defined(__PCM__) 368 .................... #elif defined(__PCM__)
369 .................... LCD_PIN_MAP lcd, lcdlat, lcdtris; 369 .................... LCD_PIN_MAP lcd, lcdlat, lcdtris;
370 .................... #byte lcd = LCD_DATA_PORT 370 .................... #byte lcd = LCD_DATA_PORT
371 .................... #byte lcdlat = LCD_DATA_PORT 371 .................... #byte lcdlat = LCD_DATA_PORT
372 .................... #byte lcdtris = LCD_DATA_PORT+0x80 372 .................... #byte lcdtris = LCD_DATA_PORT+0x80
373 .................... #elif defined(__PCH__) 373 .................... #elif defined(__PCH__)
374 .................... LCD_PIN_MAP lcd, lcdlat, lcdtris; 374 .................... LCD_PIN_MAP lcd, lcdlat, lcdtris;
375 .................... #byte lcd = LCD_DATA_PORT 375 .................... #byte lcd = LCD_DATA_PORT
376 .................... #byte lcdlat = LCD_DATA_PORT+9 376 .................... #byte lcdlat = LCD_DATA_PORT+9
377 .................... #byte lcdtris = LCD_DATA_PORT+0x12 377 .................... #byte lcdtris = LCD_DATA_PORT+0x12
378 .................... #elif defined(__PCD__) 378 .................... #elif defined(__PCD__)
379 .................... LCD_PIN_MAP lcd, lcdlat, lcdtris; 379 .................... LCD_PIN_MAP lcd, lcdlat, lcdtris;
380 .................... #word lcd = LCD_DATA_PORT 380 .................... #word lcd = LCD_DATA_PORT
381 .................... #word lcdlat = LCD_DATA_PORT+2 381 .................... #word lcdlat = LCD_DATA_PORT+2
382 .................... #word lcdtris = LCD_DATA_PORT-0x02 382 .................... #word lcdtris = LCD_DATA_PORT-0x02
383 .................... #endif 383 .................... #endif
384 .................... #endif //LCD_DATA4 not defined 384 .................... #endif //LCD_DATA4 not defined
385 .................... 385 ....................
386 .................... #ifndef LCD_TYPE 386 .................... #ifndef LCD_TYPE
387 .................... #define LCD_TYPE 2 // 0=5x7, 1=5x10, 2=2 lines 387 .................... #define LCD_TYPE 2 // 0=5x7, 1=5x10, 2=2 lines
388 .................... #endif 388 .................... #endif
389 .................... 389 ....................
390 .................... #ifndef LCD_LINE_TWO 390 .................... #ifndef LCD_LINE_TWO
391 .................... #define LCD_LINE_TWO 0x40 // LCD RAM address for the second line 391 .................... #define LCD_LINE_TWO 0x40 // LCD RAM address for the second line
392 .................... #endif 392 .................... #endif
393 .................... 393 ....................
394 .................... #ifndef LCD_LINE_LENGTH 394 .................... #ifndef LCD_LINE_LENGTH
395 .................... #define LCD_LINE_LENGTH 20 395 .................... #define LCD_LINE_LENGTH 20
396 .................... #endif 396 .................... #endif
397 .................... 397 ....................
398 .................... BYTE const LCD_INIT_STRING[4] = {0x20 | (LCD_TYPE << 2), 0xc, 1, 6}; 398 .................... BYTE const LCD_INIT_STRING[4] = {0x20 | (LCD_TYPE << 2), 0xc, 1, 6};
399 .................... // These bytes need to be sent to the LCD 399 .................... // These bytes need to be sent to the LCD
400 .................... // to start it up. 400 .................... // to start it up.
401 .................... 401 ....................
402 .................... BYTE lcd_read_nibble(void); 402 .................... BYTE lcd_read_nibble(void);
403 .................... 403 ....................
404 .................... BYTE lcd_read_byte(void) 404 .................... BYTE lcd_read_byte(void)
405 .................... { 405 .................... {
406 .................... BYTE low,high; 406 .................... BYTE low,high;
407 .................... 407 ....................
408 .................... #if defined(__PCB__) 408 .................... #if defined(__PCB__)
409 .................... set_tris_lcd(LCD_INPUT_MAP); 409 .................... set_tris_lcd(LCD_INPUT_MAP);
410 .................... #else 410 .................... #else
411 .................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7)) 411 .................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
412 .................... output_float(LCD_DATA4); 412 .................... output_float(LCD_DATA4);
413 * 413 *
414 0174: BSF 08.4 414 0174: BSF 08.4
415 .................... output_float(LCD_DATA5); 415 .................... output_float(LCD_DATA5);
416 0175: BSF 08.5 416 0175: BSF 08.5
417 .................... output_float(LCD_DATA6); 417 .................... output_float(LCD_DATA6);
418 0176: BSF 08.6 418 0176: BSF 08.6
419 .................... output_float(LCD_DATA7); 419 .................... output_float(LCD_DATA7);
420 0177: BSF 08.7 420 0177: BSF 08.7
421 .................... #else 421 .................... #else
422 .................... lcdtris.data = 0xF; 422 .................... lcdtris.data = 0xF;
423 .................... #endif 423 .................... #endif
424 .................... #endif 424 .................... #endif
425 .................... 425 ....................
426 .................... lcd_output_rw(1); 426 .................... lcd_output_rw(1);
427 0178: BCF 03.5 427 0178: BCF 03.5
428 0179: BSF 09.2 428 0179: BSF 09.2
429 017A: BSF 03.5 429 017A: BSF 03.5
430 017B: BCF 09.2 430 017B: BCF 09.2
431 .................... delay_cycles(1); 431 .................... delay_cycles(1);
432 017C: NOP 432 017C: NOP
433 .................... lcd_output_enable(1); 433 .................... lcd_output_enable(1);
434 017D: BCF 03.5 434 017D: BCF 03.5
435 017E: BSF 09.0 435 017E: BSF 09.0
436 017F: BSF 03.5 436 017F: BSF 03.5
437 0180: BCF 09.0 437 0180: BCF 09.0
438 .................... delay_cycles(1); 438 .................... delay_cycles(1);
439 0181: NOP 439 0181: NOP
440 .................... high = lcd_read_nibble(); 440 .................... high = lcd_read_nibble();
441 0182: BCF 03.5 441 0182: BCF 03.5
442 0183: CALL 13B 442 0183: CALL 13B
443 0184: MOVF 78,W 443 0184: MOVF 78,W
444 0185: MOVWF 4A 444 0185: MOVWF 52
445 .................... 445 ....................
446 .................... lcd_output_enable(0); 446 .................... lcd_output_enable(0);
447 0186: BCF 09.0 447 0186: BCF 09.0
448 0187: BSF 03.5 448 0187: BSF 03.5
449 0188: BCF 09.0 449 0188: BCF 09.0
450 .................... delay_cycles(1); 450 .................... delay_cycles(1);
451 0189: NOP 451 0189: NOP
452 .................... lcd_output_enable(1); 452 .................... lcd_output_enable(1);
453 018A: BCF 03.5 453 018A: BCF 03.5
454 018B: BSF 09.0 454 018B: BSF 09.0
455 018C: BSF 03.5 455 018C: BSF 03.5
456 018D: BCF 09.0 456 018D: BCF 09.0
457 .................... delay_us(1); 457 .................... delay_us(1);
458 018E: GOTO 18F 458 018E: GOTO 18F
459 .................... low = lcd_read_nibble(); 459 .................... low = lcd_read_nibble();
460 018F: BCF 03.5 460 018F: BCF 03.5
461 0190: CALL 13B 461 0190: CALL 13B
462 0191: MOVF 78,W 462 0191: MOVF 78,W
463 0192: MOVWF 49 463 0192: MOVWF 51
464 .................... 464 ....................
465 .................... lcd_output_enable(0); 465 .................... lcd_output_enable(0);
466 0193: BCF 09.0 466 0193: BCF 09.0
467 0194: BSF 03.5 467 0194: BSF 03.5
468 0195: BCF 09.0 468 0195: BCF 09.0
469 .................... 469 ....................
470 .................... #if defined(__PCB__) 470 .................... #if defined(__PCB__)
471 .................... set_tris_lcd(LCD_OUTPUT_MAP); 471 .................... set_tris_lcd(LCD_OUTPUT_MAP);
472 .................... #else 472 .................... #else
473 .................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7)) 473 .................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
474 .................... output_drive(LCD_DATA4); 474 .................... output_drive(LCD_DATA4);
475 0196: BCF 08.4 475 0196: BCF 08.4
476 .................... output_drive(LCD_DATA5); 476 .................... output_drive(LCD_DATA5);
477 0197: BCF 08.5 477 0197: BCF 08.5
478 .................... output_drive(LCD_DATA6); 478 .................... output_drive(LCD_DATA6);
479 0198: BCF 08.6 479 0198: BCF 08.6
480 .................... output_drive(LCD_DATA7); 480 .................... output_drive(LCD_DATA7);
481 0199: BCF 08.7 481 0199: BCF 08.7
482 .................... #else 482 .................... #else
483 .................... lcdtris.data = 0x0; 483 .................... lcdtris.data = 0x0;
484 .................... #endif 484 .................... #endif
485 .................... #endif 485 .................... #endif
486 .................... 486 ....................
487 .................... return( (high<<4) | low); 487 .................... return( (high<<4) | low);
488 019A: BCF 03.5 488 019A: BCF 03.5
489 019B: SWAPF 4A,W 489 019B: SWAPF 52,W
490 019C: MOVWF 77 490 019C: MOVWF 77
491 019D: MOVLW F0 491 019D: MOVLW F0
492 019E: ANDWF 77,F 492 019E: ANDWF 77,F
493 019F: MOVF 77,W 493 019F: MOVF 77,W
494 01A0: IORWF 49,W 494 01A0: IORWF 51,W
495 01A1: MOVWF 78 495 01A1: MOVWF 78
496 .................... } 496 .................... }
497 .................... 497 ....................
498 .................... BYTE lcd_read_nibble(void) 498 .................... BYTE lcd_read_nibble(void)
499 .................... { 499 .................... {
500 .................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7)) 500 .................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
501 * 501 *
502 013B: CLRF 4B 502 013B: CLRF 53
503 .................... BYTE n = 0x00; 503 .................... BYTE n = 0x00;
504 .................... 504 ....................
505 .................... /* Read the data port */ 505 .................... /* Read the data port */
506 .................... n |= input(LCD_DATA4); 506 .................... n |= input(LCD_DATA4);
507 013C: BSF 03.5 507 013C: BSF 03.5
508 013D: BSF 08.4 508 013D: BSF 08.4
509 013E: MOVLW 00 509 013E: MOVLW 00
510 013F: BCF 03.5 510 013F: BCF 03.5
511 0140: BTFSC 08.4 511 0140: BTFSC 08.4
512 0141: MOVLW 01 512 0141: MOVLW 01
513 0142: IORWF 4B,F 513 0142: IORWF 53,F
514 .................... n |= input(LCD_DATA5) << 1; 514 .................... n |= input(LCD_DATA5) << 1;
515 0143: BSF 03.5 515 0143: BSF 03.5
516 0144: BSF 08.5 516 0144: BSF 08.5
517 0145: MOVLW 00 517 0145: MOVLW 00
518 0146: BCF 03.5 518 0146: BCF 03.5
519 0147: BTFSC 08.5 519 0147: BTFSC 08.5
520 0148: MOVLW 01 520 0148: MOVLW 01
521 0149: MOVWF 77 521 0149: MOVWF 77
522 014A: BCF 03.0 522 014A: BCF 03.0
523 014B: RLF 77,F 523 014B: RLF 77,F
524 014C: MOVF 77,W 524 014C: MOVF 77,W
525 014D: IORWF 4B,F 525 014D: IORWF 53,F
526 .................... n |= input(LCD_DATA6) << 2; 526 .................... n |= input(LCD_DATA6) << 2;
527 014E: BSF 03.5 527 014E: BSF 03.5
528 014F: BSF 08.6 528 014F: BSF 08.6
529 0150: MOVLW 00 529 0150: MOVLW 00
530 0151: BCF 03.5 530 0151: BCF 03.5
531 0152: BTFSC 08.6 531 0152: BTFSC 08.6
532 0153: MOVLW 01 532 0153: MOVLW 01
533 0154: MOVWF 77 533 0154: MOVWF 77
534 0155: RLF 77,F 534 0155: RLF 77,F
535 0156: RLF 77,F 535 0156: RLF 77,F
536 0157: MOVLW FC 536 0157: MOVLW FC
537 0158: ANDWF 77,F 537 0158: ANDWF 77,F
538 0159: MOVF 77,W 538 0159: MOVF 77,W
539 015A: IORWF 4B,F 539 015A: IORWF 53,F
540 .................... n |= input(LCD_DATA7) << 3; 540 .................... n |= input(LCD_DATA7) << 3;
541 015B: BSF 03.5 541 015B: BSF 03.5
542 015C: BSF 08.7 542 015C: BSF 08.7
543 015D: MOVLW 00 543 015D: MOVLW 00
544 015E: BCF 03.5 544 015E: BCF 03.5
545 015F: BTFSC 08.7 545 015F: BTFSC 08.7
546 0160: MOVLW 01 546 0160: MOVLW 01
547 0161: MOVWF 77 547 0161: MOVWF 77
548 0162: RLF 77,F 548 0162: RLF 77,F
549 0163: RLF 77,F 549 0163: RLF 77,F
550 0164: RLF 77,F 550 0164: RLF 77,F
551 0165: MOVLW F8 551 0165: MOVLW F8
552 0166: ANDWF 77,F 552 0166: ANDWF 77,F
553 0167: MOVF 77,W 553 0167: MOVF 77,W
554 0168: IORWF 4B,F 554 0168: IORWF 53,F
555 .................... 555 ....................
556 .................... return(n); 556 .................... return(n);
557 0169: MOVF 4B,W 557 0169: MOVF 53,W
558 016A: MOVWF 78 558 016A: MOVWF 78
559 .................... #else 559 .................... #else
560 .................... return(lcd.data); 560 .................... return(lcd.data);
561 .................... #endif 561 .................... #endif
562 .................... } 562 .................... }
563 016B: RETURN 563 016B: RETURN
564 .................... 564 ....................
565 .................... void lcd_send_nibble(BYTE n) 565 .................... void lcd_send_nibble(BYTE n)
566 .................... { 566 .................... {
567 .................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7)) 567 .................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
568 .................... /* Write to the data port */ 568 .................... /* Write to the data port */
569 .................... output_bit(LCD_DATA4, bit_test(n, 0)); 569 .................... output_bit(LCD_DATA4, bit_test(n, 0));
570 * 570 *
571 010F: BTFSC 4A.0 571 010F: BTFSC 52.0
572 0110: GOTO 113 572 0110: GOTO 113
573 0111: BCF 08.4 573 0111: BCF 08.4
574 0112: GOTO 114 574 0112: GOTO 114
575 0113: BSF 08.4 575 0113: BSF 08.4
576 0114: BSF 03.5 576 0114: BSF 03.5
577 0115: BCF 08.4 577 0115: BCF 08.4
578 .................... output_bit(LCD_DATA5, bit_test(n, 1)); 578 .................... output_bit(LCD_DATA5, bit_test(n, 1));
579 0116: BCF 03.5 579 0116: BCF 03.5
580 0117: BTFSC 4A.1 580 0117: BTFSC 52.1
581 0118: GOTO 11B 581 0118: GOTO 11B
582 0119: BCF 08.5 582 0119: BCF 08.5
583 011A: GOTO 11C 583 011A: GOTO 11C
584 011B: BSF 08.5 584 011B: BSF 08.5
585 011C: BSF 03.5 585 011C: BSF 03.5
586 011D: BCF 08.5 586 011D: BCF 08.5
587 .................... output_bit(LCD_DATA6, bit_test(n, 2)); 587 .................... output_bit(LCD_DATA6, bit_test(n, 2));
588 011E: BCF 03.5 588 011E: BCF 03.5
589 011F: BTFSC 4A.2 589 011F: BTFSC 52.2
590 0120: GOTO 123 590 0120: GOTO 123
591 0121: BCF 08.6 591 0121: BCF 08.6
592 0122: GOTO 124 592 0122: GOTO 124
593 0123: BSF 08.6 593 0123: BSF 08.6
594 0124: BSF 03.5 594 0124: BSF 03.5
595 0125: BCF 08.6 595 0125: BCF 08.6
596 .................... output_bit(LCD_DATA7, bit_test(n, 3)); 596 .................... output_bit(LCD_DATA7, bit_test(n, 3));
597 0126: BCF 03.5 597 0126: BCF 03.5
598 0127: BTFSC 4A.3 598 0127: BTFSC 52.3
599 0128: GOTO 12B 599 0128: GOTO 12B
600 0129: BCF 08.7 600 0129: BCF 08.7
601 012A: GOTO 12C 601 012A: GOTO 12C
602 012B: BSF 08.7 602 012B: BSF 08.7
603 012C: BSF 03.5 603 012C: BSF 03.5
604 012D: BCF 08.7 604 012D: BCF 08.7
605 .................... #else 605 .................... #else
606 .................... lcdlat.data = n; 606 .................... lcdlat.data = n;
607 .................... #endif 607 .................... #endif
608 .................... 608 ....................
609 .................... delay_cycles(1); 609 .................... delay_cycles(1);
610 012E: NOP 610 012E: NOP
611 .................... lcd_output_enable(1); 611 .................... lcd_output_enable(1);
612 012F: BCF 03.5 612 012F: BCF 03.5
613 0130: BSF 09.0 613 0130: BSF 09.0
614 0131: BSF 03.5 614 0131: BSF 03.5
615 0132: BCF 09.0 615 0132: BCF 09.0
616 .................... delay_us(2); 616 .................... delay_us(2);
617 0133: GOTO 134 617 0133: GOTO 134
618 0134: GOTO 135 618 0134: GOTO 135
619 .................... lcd_output_enable(0); 619 .................... lcd_output_enable(0);
620 0135: BCF 03.5 620 0135: BCF 03.5
621 0136: BCF 09.0 621 0136: BCF 09.0
622 0137: BSF 03.5 622 0137: BSF 03.5
623 0138: BCF 09.0 623 0138: BCF 09.0
624 .................... } 624 .................... }
625 0139: BCF 03.5 625 0139: BCF 03.5
626 013A: RETURN 626 013A: RETURN
627 .................... 627 ....................
628 .................... void lcd_send_byte(BYTE address, BYTE n) 628 .................... void lcd_send_byte(BYTE address, BYTE n)
629 .................... { 629 .................... {
630 .................... #if defined(__PCB__) 630 .................... #if defined(__PCB__)
631 .................... set_tris_lcd(LCD_OUTPUT_MAP); 631 .................... set_tris_lcd(LCD_OUTPUT_MAP);
632 .................... #else 632 .................... #else
633 .................... lcd_enable_tris(); 633 .................... lcd_enable_tris();
634 * 634 *
635 016C: BSF 03.5 635 016C: BSF 03.5
636 016D: BCF 09.0 636 016D: BCF 09.0
637 .................... lcd_rs_tris(); 637 .................... lcd_rs_tris();
638 016E: BCF 09.1 638 016E: BCF 09.1
639 .................... lcd_rw_tris(); 639 .................... lcd_rw_tris();
640 016F: BCF 09.2 640 016F: BCF 09.2
641 .................... #endif 641 .................... #endif
642 .................... 642 ....................
643 .................... lcd_output_rs(0); 643 .................... lcd_output_rs(0);
644 0170: BCF 03.5 644 0170: BCF 03.5
645 0171: BCF 09.1 645 0171: BCF 09.1
646 0172: BSF 03.5 646 0172: BSF 03.5
647 0173: BCF 09.1 647 0173: BCF 09.1
648 .................... while ( bit_test(lcd_read_byte(),7) ) ; 648 .................... while ( bit_test(lcd_read_byte(),7) ) ;
649 * 649 *
650 01A2: MOVF 78,W 650 01A2: MOVF 78,W
651 01A3: MOVWF 49 651 01A3: MOVWF 51
652 01A4: BTFSS 49.7 652 01A4: BTFSS 51.7
653 01A5: GOTO 1A8 653 01A5: GOTO 1A8
654 01A6: BSF 03.5 654 01A6: BSF 03.5
655 01A7: GOTO 174 655 01A7: GOTO 174
656 .................... lcd_output_rs(address); 656 .................... lcd_output_rs(address);
657 01A8: MOVF 47,F 657 01A8: MOVF 4F,F
658 01A9: BTFSS 03.2 658 01A9: BTFSS 03.2
659 01AA: GOTO 1AD 659 01AA: GOTO 1AD
660 01AB: BCF 09.1 660 01AB: BCF 09.1
661 01AC: GOTO 1AE 661 01AC: GOTO 1AE
662 01AD: BSF 09.1 662 01AD: BSF 09.1
663 01AE: BSF 03.5 663 01AE: BSF 03.5
664 01AF: BCF 09.1 664 01AF: BCF 09.1
665 .................... delay_cycles(1); 665 .................... delay_cycles(1);
666 01B0: NOP 666 01B0: NOP
667 .................... lcd_output_rw(0); 667 .................... lcd_output_rw(0);
668 01B1: BCF 03.5 668 01B1: BCF 03.5
669 01B2: BCF 09.2 669 01B2: BCF 09.2
670 01B3: BSF 03.5 670 01B3: BSF 03.5
671 01B4: BCF 09.2 671 01B4: BCF 09.2
672 .................... delay_cycles(1); 672 .................... delay_cycles(1);
673 01B5: NOP 673 01B5: NOP
674 .................... lcd_output_enable(0); 674 .................... lcd_output_enable(0);
675 01B6: BCF 03.5 675 01B6: BCF 03.5
676 01B7: BCF 09.0 676 01B7: BCF 09.0
677 01B8: BSF 03.5 677 01B8: BSF 03.5
678 01B9: BCF 09.0 678 01B9: BCF 09.0
679 .................... lcd_send_nibble(n >> 4); 679 .................... lcd_send_nibble(n >> 4);
680 01BA: BCF 03.5 680 01BA: BCF 03.5
681 01BB: SWAPF 48,W 681 01BB: SWAPF 50,W
682 01BC: MOVWF 49 682 01BC: MOVWF 51
683 01BD: MOVLW 0F 683 01BD: MOVLW 0F
684 01BE: ANDWF 49,F 684 01BE: ANDWF 51,F
685 01BF: MOVF 49,W 685 01BF: MOVF 51,W
686 01C0: MOVWF 4A 686 01C0: MOVWF 52
687 01C1: CALL 10F 687 01C1: CALL 10F
688 .................... lcd_send_nibble(n & 0xf); 688 .................... lcd_send_nibble(n & 0xf);
689 01C2: MOVF 48,W 689 01C2: MOVF 50,W
690 01C3: ANDLW 0F 690 01C3: ANDLW 0F
691 01C4: MOVWF 49 691 01C4: MOVWF 51
692 01C5: MOVWF 4A 692 01C5: MOVWF 52
693 01C6: CALL 10F 693 01C6: CALL 10F
694 .................... } 694 .................... }
695 01C7: RETURN 695 01C7: RETURN
696 .................... 696 ....................
697 .................... #if defined(LCD_EXTENDED_NEWLINE) 697 .................... #if defined(LCD_EXTENDED_NEWLINE)
698 .................... unsigned int8 g_LcdX, g_LcdY; 698 .................... unsigned int8 g_LcdX, g_LcdY;
699 .................... #endif 699 .................... #endif
700 .................... 700 ....................
701 .................... void lcd_init(void) 701 .................... void lcd_init(void)
702 .................... { 702 .................... {
703 .................... BYTE i; 703 .................... BYTE i;
704 .................... 704 ....................
705 .................... #if defined(__PCB__) 705 .................... #if defined(__PCB__)
706 .................... set_tris_lcd(LCD_OUTPUT_MAP); 706 .................... set_tris_lcd(LCD_OUTPUT_MAP);
707 .................... #else 707 .................... #else
708 .................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7)) 708 .................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
709 .................... output_drive(LCD_DATA4); 709 .................... output_drive(LCD_DATA4);
710 01C8: BSF 03.5 710 01C8: BSF 03.5
711 01C9: BCF 08.4 711 01C9: BCF 08.4
712 .................... output_drive(LCD_DATA5); 712 .................... output_drive(LCD_DATA5);
713 01CA: BCF 08.5 713 01CA: BCF 08.5
714 .................... output_drive(LCD_DATA6); 714 .................... output_drive(LCD_DATA6);
715 01CB: BCF 08.6 715 01CB: BCF 08.6
716 .................... output_drive(LCD_DATA7); 716 .................... output_drive(LCD_DATA7);
717 01CC: BCF 08.7 717 01CC: BCF 08.7
718 .................... #else 718 .................... #else
719 .................... lcdtris.data = 0x0; 719 .................... lcdtris.data = 0x0;
720 .................... #endif 720 .................... #endif
721 .................... lcd_enable_tris(); 721 .................... lcd_enable_tris();
722 01CD: BCF 09.0 722 01CD: BCF 09.0
723 .................... lcd_rs_tris(); 723 .................... lcd_rs_tris();
724 01CE: BCF 09.1 724 01CE: BCF 09.1
725 .................... lcd_rw_tris(); 725 .................... lcd_rw_tris();
726 01CF: BCF 09.2 726 01CF: BCF 09.2
727 .................... #endif 727 .................... #endif
728 .................... 728 ....................
729 .................... lcd_output_rs(0); 729 .................... lcd_output_rs(0);
730 01D0: BCF 03.5 730 01D0: BCF 03.5
731 01D1: BCF 09.1 731 01D1: BCF 09.1
732 01D2: BSF 03.5 732 01D2: BSF 03.5
733 01D3: BCF 09.1 733 01D3: BCF 09.1
734 .................... lcd_output_rw(0); 734 .................... lcd_output_rw(0);
735 01D4: BCF 03.5 735 01D4: BCF 03.5
736 01D5: BCF 09.2 736 01D5: BCF 09.2
737 01D6: BSF 03.5 737 01D6: BSF 03.5
738 01D7: BCF 09.2 738 01D7: BCF 09.2
739 .................... lcd_output_enable(0); 739 .................... lcd_output_enable(0);
740 01D8: BCF 03.5 740 01D8: BCF 03.5
741 01D9: BCF 09.0 741 01D9: BCF 09.0
742 01DA: BSF 03.5 742 01DA: BSF 03.5
743 01DB: BCF 09.0 743 01DB: BCF 09.0
744 .................... 744 ....................
745 .................... delay_ms(15); 745 .................... delay_ms(15);
746 01DC: MOVLW 0F 746 01DC: MOVLW 0F
747 01DD: BCF 03.5 747 01DD: BCF 03.5
748 01DE: MOVWF 43 748 01DE: MOVWF 4B
749 01DF: CALL 0FB 749 01DF: CALL 0FB
750 .................... for(i=1;i<=3;++i) 750 .................... for(i=1;i<=3;++i)
751 01E0: MOVLW 01 751 01E0: MOVLW 01
752 01E1: MOVWF 35 752 01E1: MOVWF 3D
753 01E2: MOVF 35,W 753 01E2: MOVF 3D,W
754 01E3: SUBLW 03 754 01E3: SUBLW 03
755 01E4: BTFSS 03.0 755 01E4: BTFSS 03.0
756 01E5: GOTO 1EE 756 01E5: GOTO 1EE
757 .................... { 757 .................... {
758 .................... lcd_send_nibble(3); 758 .................... lcd_send_nibble(3);
759 01E6: MOVLW 03 759 01E6: MOVLW 03
760 01E7: MOVWF 4A 760 01E7: MOVWF 52
761 01E8: CALL 10F 761 01E8: CALL 10F
762 .................... delay_ms(5); 762 .................... delay_ms(5);
763 01E9: MOVLW 05 763 01E9: MOVLW 05
764 01EA: MOVWF 43 764 01EA: MOVWF 4B
765 01EB: CALL 0FB 765 01EB: CALL 0FB
766 .................... } 766 .................... }
767 01EC: INCF 35,F 767 01EC: INCF 3D,F
768 01ED: GOTO 1E2 768 01ED: GOTO 1E2
769 .................... 769 ....................
770 .................... lcd_send_nibble(2); 770 .................... lcd_send_nibble(2);
771 01EE: MOVLW 02 771 01EE: MOVLW 02
772 01EF: MOVWF 4A 772 01EF: MOVWF 52
773 01F0: CALL 10F 773 01F0: CALL 10F
774 .................... for(i=0;i<=3;++i) 774 .................... for(i=0;i<=3;++i)
775 01F1: CLRF 35 775 01F1: CLRF 3D
776 01F2: MOVF 35,W 776 01F2: MOVF 3D,W
777 01F3: SUBLW 03 777 01F3: SUBLW 03
778 01F4: BTFSS 03.0 778 01F4: BTFSS 03.0
779 01F5: GOTO 1FF 779 01F5: GOTO 1FF
780 .................... lcd_send_byte(0,LCD_INIT_STRING[i]); 780 .................... lcd_send_byte(0,LCD_INIT_STRING[i]);
781 01F6: MOVF 35,W 781 01F6: MOVF 3D,W
782 01F7: CALL 004 782 01F7: CALL 004
783 01F8: MOVWF 36 783 01F8: MOVWF 3E
784 01F9: CLRF 47 784 01F9: CLRF 4F
785 01FA: MOVF 36,W 785 01FA: MOVF 3E,W
786 01FB: MOVWF 48 786 01FB: MOVWF 50
787 01FC: CALL 16C 787 01FC: CALL 16C
788 .................... 788 ....................
789 .................... #if defined(LCD_EXTENDED_NEWLINE) 789 .................... #if defined(LCD_EXTENDED_NEWLINE)
790 01FD: INCF 35,F 790 01FD: INCF 3D,F
791 01FE: GOTO 1F2 791 01FE: GOTO 1F2
792 .................... g_LcdX = 0; 792 .................... g_LcdX = 0;
793 .................... g_LcdY = 0; 793 .................... g_LcdY = 0;
794 .................... #endif 794 .................... #endif
795 .................... } 795 .................... }
796 01FF: RETURN 796 01FF: RETURN
797 .................... 797 ....................
798 .................... void lcd_gotoxy(BYTE x, BYTE y) 798 .................... void lcd_gotoxy(BYTE x, BYTE y)
799 .................... { 799 .................... {
800 .................... BYTE address; 800 .................... BYTE address;
801 .................... 801 ....................
802 .................... if(y!=1) 802 .................... if(y!=1)
803 0200: DECFSZ 44,W 803 0200: DECFSZ 4C,W
804 0201: GOTO 203 804 0201: GOTO 203
805 0202: GOTO 206 805 0202: GOTO 206
806 .................... address=LCD_LINE_TWO; 806 .................... address=LCD_LINE_TWO;
807 0203: MOVLW 40 807 0203: MOVLW 40
808 0204: MOVWF 45 808 0204: MOVWF 4D
809 .................... else 809 .................... else
810 0205: GOTO 207 810 0205: GOTO 207
811 .................... address=0; 811 .................... address=0;
812 0206: CLRF 45 812 0206: CLRF 4D
813 .................... 813 ....................
814 .................... address+=x-1; 814 .................... address+=x-1;
815 0207: MOVLW 01 815 0207: MOVLW 01
816 0208: SUBWF 43,W 816 0208: SUBWF 4B,W
817 0209: ADDWF 45,F 817 0209: ADDWF 4D,F
818 .................... lcd_send_byte(0,0x80|address); 818 .................... lcd_send_byte(0,0x80|address);
819 020A: MOVF 45,W 819 020A: MOVF 4D,W
820 020B: IORLW 80 820 020B: IORLW 80
821 020C: MOVWF 46 821 020C: MOVWF 4E
822 020D: CLRF 47 822 020D: CLRF 4F
823 020E: MOVF 46,W 823 020E: MOVF 4E,W
824 020F: MOVWF 48 824 020F: MOVWF 50
825 0210: CALL 16C 825 0210: CALL 16C
826 .................... 826 ....................
827 .................... #if defined(LCD_EXTENDED_NEWLINE) 827 .................... #if defined(LCD_EXTENDED_NEWLINE)
828 .................... g_LcdX = x - 1; 828 .................... g_LcdX = x - 1;
829 .................... g_LcdY = y - 1; 829 .................... g_LcdY = y - 1;
830 .................... #endif 830 .................... #endif
831 .................... } 831 .................... }
832 0211: RETURN 832 0211: RETURN
833 .................... 833 ....................
834 .................... void lcd_putc(char c) 834 .................... void lcd_putc(char c)
835 .................... { 835 .................... {
836 .................... switch (c) 836 .................... switch (c)
837 .................... { 837 .................... {
838 0212: MOVF 42,W 838 0212: MOVF 4A,W
839 0213: XORLW 07 839 0213: XORLW 07
840 0214: BTFSC 03.2 840 0214: BTFSC 03.2
841 0215: GOTO 220 841 0215: GOTO 220
842 0216: XORLW 0B 842 0216: XORLW 0B
843 0217: BTFSC 03.2 843 0217: BTFSC 03.2
844 0218: GOTO 225 844 0218: GOTO 225
845 0219: XORLW 06 845 0219: XORLW 06
846 021A: BTFSC 03.2 846 021A: BTFSC 03.2
847 021B: GOTO 22D 847 021B: GOTO 22D
848 021C: XORLW 02 848 021C: XORLW 02
849 021D: BTFSC 03.2 849 021D: BTFSC 03.2
850 021E: GOTO 233 850 021E: GOTO 233
851 021F: GOTO 238 851 021F: GOTO 238
852 .................... case '\a' : lcd_gotoxy(1,1); break; 852 .................... case '\a' : lcd_gotoxy(1,1); break;
853 0220: MOVLW 01 853 0220: MOVLW 01
854 0221: MOVWF 43 854 0221: MOVWF 4B
855 0222: MOVWF 44 855 0222: MOVWF 4C
856 0223: CALL 200 856 0223: CALL 200
857 0224: GOTO 23E 857 0224: GOTO 23E
858 .................... 858 ....................
859 .................... case '\f' : lcd_send_byte(0,1); 859 .................... case '\f' : lcd_send_byte(0,1);
860 0225: CLRF 47 860 0225: CLRF 4F
861 0226: MOVLW 01 861 0226: MOVLW 01
862 0227: MOVWF 48 862 0227: MOVWF 50
863 0228: CALL 16C 863 0228: CALL 16C
864 .................... delay_ms(2); 864 .................... delay_ms(2);
865 0229: MOVLW 02 865 0229: MOVLW 02
866 022A: MOVWF 43 866 022A: MOVWF 4B
867 022B: CALL 0FB 867 022B: CALL 0FB
868 .................... #if defined(LCD_EXTENDED_NEWLINE) 868 .................... #if defined(LCD_EXTENDED_NEWLINE)
869 .................... g_LcdX = 0; 869 .................... g_LcdX = 0;
870 .................... g_LcdY = 0; 870 .................... g_LcdY = 0;
871 .................... #endif 871 .................... #endif
872 .................... break; 872 .................... break;
873 022C: GOTO 23E 873 022C: GOTO 23E
874 .................... 874 ....................
875 .................... #if defined(LCD_EXTENDED_NEWLINE) 875 .................... #if defined(LCD_EXTENDED_NEWLINE)
876 .................... case '\r' : lcd_gotoxy(1, g_LcdY+1); break; 876 .................... case '\r' : lcd_gotoxy(1, g_LcdY+1); break;
877 .................... case '\n' : 877 .................... case '\n' :
878 .................... while (g_LcdX++ < LCD_LINE_LENGTH) 878 .................... while (g_LcdX++ < LCD_LINE_LENGTH)
879 .................... { 879 .................... {
880 .................... lcd_send_byte(1, ' '); 880 .................... lcd_send_byte(1, ' ');
881 .................... } 881 .................... }
882 .................... lcd_gotoxy(1, g_LcdY+2); 882 .................... lcd_gotoxy(1, g_LcdY+2);
883 .................... break; 883 .................... break;
884 .................... #else 884 .................... #else
885 .................... case '\n' : lcd_gotoxy(1,2); break; 885 .................... case '\n' : lcd_gotoxy(1,2); break;
886 022D: MOVLW 01 886 022D: MOVLW 01
887 022E: MOVWF 43 887 022E: MOVWF 4B
888 022F: MOVLW 02 888 022F: MOVLW 02
889 0230: MOVWF 44 889 0230: MOVWF 4C
890 0231: CALL 200 890 0231: CALL 200
891 0232: GOTO 23E 891 0232: GOTO 23E
892 .................... #endif 892 .................... #endif
893 .................... 893 ....................
894 .................... case '\b' : lcd_send_byte(0,0x10); break; 894 .................... case '\b' : lcd_send_byte(0,0x10); break;
895 0233: CLRF 47 895 0233: CLRF 4F
896 0234: MOVLW 10 896 0234: MOVLW 10
897 0235: MOVWF 48 897 0235: MOVWF 50
898 0236: CALL 16C 898 0236: CALL 16C
899 0237: GOTO 23E 899 0237: GOTO 23E
900 .................... 900 ....................
901 .................... #if defined(LCD_EXTENDED_NEWLINE) 901 .................... #if defined(LCD_EXTENDED_NEWLINE)
902 .................... default : 902 .................... default :
903 .................... if (g_LcdX < LCD_LINE_LENGTH) 903 .................... if (g_LcdX < LCD_LINE_LENGTH)
904 .................... { 904 .................... {
905 .................... lcd_send_byte(1, c); 905 .................... lcd_send_byte(1, c);
906 .................... g_LcdX++; 906 .................... g_LcdX++;
907 .................... } 907 .................... }
908 .................... break; 908 .................... break;
909 .................... #else 909 .................... #else
910 .................... default : lcd_send_byte(1,c); break; 910 .................... default : lcd_send_byte(1,c); break;
911 0238: MOVLW 01 911 0238: MOVLW 01
912 0239: MOVWF 47 912 0239: MOVWF 4F
913 023A: MOVF 42,W 913 023A: MOVF 4A,W
914 023B: MOVWF 48 914 023B: MOVWF 50
915 023C: CALL 16C 915 023C: CALL 16C
916 023D: GOTO 23E 916 023D: GOTO 23E
917 .................... #endif 917 .................... #endif
918 .................... } 918 .................... }
919 .................... } 919 .................... }
920 023E: RETURN 920 023E: RETURN
921 .................... 921 ....................
922 .................... char lcd_getc(BYTE x, BYTE y) 922 .................... char lcd_getc(BYTE x, BYTE y)
923 .................... { 923 .................... {
924 .................... char value; 924 .................... char value;
925 .................... 925 ....................
926 .................... lcd_gotoxy(x,y); 926 .................... lcd_gotoxy(x,y);
927 .................... while ( bit_test(lcd_read_byte(),7) ); // wait until busy flag is low 927 .................... while ( bit_test(lcd_read_byte(),7) ); // wait until busy flag is low
928 .................... lcd_output_rs(1); 928 .................... lcd_output_rs(1);
929 .................... value = lcd_read_byte(); 929 .................... value = lcd_read_byte();
930 .................... lcd_output_rs(0); 930 .................... lcd_output_rs(0);
931 .................... 931 ....................
932 .................... return(value); 932 .................... return(value);
933 .................... } 933 .................... }
934 .................... 934 ....................
935 .................... 935 ....................
936 .................... #include "../SHT25.h" 936 .................... #include "../SHT25.h"
937 .................... 937 ....................
938 .................... #define SHT25_HEATER_ON 0x04 938 .................... #define SHT25_HEATER_ON 0x04
939 .................... #define SHT25_HEATER_OFF 0x00 939 .................... #define SHT25_HEATER_OFF 0x00
940 .................... #define SHT25_OTP_reload_off 0x02 940 .................... #define SHT25_OTP_reload_off 0x02
941 .................... #define SHT25_RH12_T14 0x00 941 .................... #define SHT25_RH12_T14 0x00
942 .................... #define SHT25_RH8_T12 0x01 942 .................... #define SHT25_RH8_T12 0x01
943 .................... #define SHT25_RH10_T13 0x80 943 .................... #define SHT25_RH10_T13 0x80
944 .................... #define SHT25_RH11_T11 0x81 944 .................... #define SHT25_RH11_T11 0x81
945 .................... 945 ....................
946 .................... #define SHT25_ADDR 0x80 946 .................... #define SHT25_ADDR 0x80
947 .................... 947 ....................
948 .................... #include "SHT25.c" 948 .................... #include "SHT25.c"
949 .................... void SHT25_soft_reset() 949 .................... void SHT25_soft_reset()
950 .................... { 950 .................... {
951 .................... i2c_start(); // Start condition 951 .................... i2c_start(); // Start condition
952 .................... i2c_write(0x80); // Device address 952 .................... i2c_write(0x80); // Device address
953 .................... i2c_write(0xFE); // Device command 953 .................... i2c_write(0xFE); // Device command
954 .................... i2c_stop(); // Stop condition 954 .................... i2c_stop(); // Stop condition
955 .................... } 955 .................... }
956 .................... 956 ....................
957 .................... unsigned int8 SHT25_setup(unsigned int8 setup_reg ) // writes to status register and returns its value 957 .................... unsigned int8 SHT25_setup(unsigned int8 setup_reg ) // writes to status register and returns its value
958 .................... { 958 .................... {
959 .................... unsigned int8 reg; 959 .................... unsigned int8 reg;
960 .................... 960 ....................
961 .................... i2c_start(); // Start condition 961 .................... i2c_start(); // Start condition
962 .................... i2c_write(SHT25_ADDR); // Device address 962 .................... i2c_write(SHT25_ADDR); // Device address
963 .................... i2c_write(0xE7); // Device command 963 .................... i2c_write(0xE7); // Device command
964 .................... 964 ....................
965 .................... i2c_start(); // Start condition 965 .................... i2c_start(); // Start condition
966 .................... i2c_write(SHT25_ADDR+1); // Device address 966 .................... i2c_write(SHT25_ADDR+1); // Device address
967 .................... reg=i2c_read(0); // Read status actual status register 967 .................... reg=i2c_read(0); // Read status actual status register
968 .................... 968 ....................
969 .................... reg = (reg & 0x3A) | setup_reg; 969 .................... reg = (reg & 0x3A) | setup_reg;
970 .................... 970 ....................
971 .................... i2c_start(); // Start condition 971 .................... i2c_start(); // Start condition
972 .................... i2c_write(SHT25_ADDR); // Device address 972 .................... i2c_write(SHT25_ADDR); // Device address
973 .................... i2c_write(0xE6); // Write to status register 973 .................... i2c_write(0xE6); // Write to status register
974 .................... i2c_write(reg); // Device command 974 .................... i2c_write(reg); // Device command
975 .................... i2c_stop(); // Stop condition 975 .................... i2c_stop(); // Stop condition
976 .................... 976 ....................
977 .................... delay_ms(10); 977 .................... delay_ms(10);
978 .................... 978 ....................
979 .................... i2c_start(); // Start condition 979 .................... i2c_start(); // Start condition
980 .................... i2c_write(SHT25_ADDR); // Device address 980 .................... i2c_write(SHT25_ADDR); // Device address
981 .................... i2c_write(0xE7); // Device command 981 .................... i2c_write(0xE7); // Device command
982 .................... 982 ....................
983 .................... i2c_start(); // Start condition 983 .................... i2c_start(); // Start condition
984 .................... i2c_write(SHT25_ADDR+1); // Device address 984 .................... i2c_write(SHT25_ADDR+1); // Device address
985 .................... reg=i2c_read(0); // Read status actual status register 985 .................... reg=i2c_read(0); // Read status actual status register
986 .................... 986 ....................
987 .................... return (reg); 987 .................... return (reg);
988 .................... } 988 .................... }
989 .................... 989 ....................
990 .................... 990 ....................
991 .................... float SHT25_get_temp() 991 .................... float SHT25_get_temp()
992 .................... { 992 .................... {
993 .................... unsigned int8 MSB, LSB, Check; 993 .................... unsigned int8 MSB, LSB, Check;
994 .................... unsigned int16 data; 994 .................... unsigned int16 data;
995 .................... 995 ....................
996 .................... i2c_start(); 996 .................... i2c_start();
997 * 997 *
998 0567: BSF 20.4 998 0567: BSF 20.4
999 0568: MOVF 20,W 999 0568: MOVF 20,W
1000 0569: BSF 03.5 1000 0569: BSF 03.5
1001 056A: MOVWF 07 1001 056A: MOVWF 07
1002 056B: NOP 1002 056B: NOP
1003 056C: BCF 03.5 1003 056C: BCF 03.5
1004 056D: BSF 20.3 1004 056D: BSF 20.3
1005 056E: MOVF 20,W 1005 056E: MOVF 20,W
1006 056F: BSF 03.5 1006 056F: BSF 03.5
1007 0570: MOVWF 07 1007 0570: MOVWF 07
1008 0571: NOP 1008 0571: NOP
1009 0572: BCF 03.5 1009 0572: BCF 03.5
1010 0573: BTFSS 07.3 1010 0573: BTFSS 07.3
1011 0574: GOTO 573 1011 0574: GOTO 573
1012 0575: BCF 07.4 1012 0575: BCF 07.4
1013 0576: BCF 20.4 1013 0576: BCF 20.4
1014 0577: MOVF 20,W 1014 0577: MOVF 20,W
1015 0578: BSF 03.5 1015 0578: BSF 03.5
1016 0579: MOVWF 07 1016 0579: MOVWF 07
1017 057A: NOP 1017 057A: NOP
1018 057B: BCF 03.5 1018 057B: BCF 03.5
1019 057C: BCF 07.3 1019 057C: BCF 07.3
1020 057D: BCF 20.3 1020 057D: BCF 20.3
1021 057E: MOVF 20,W 1021 057E: MOVF 20,W
1022 057F: BSF 03.5 1022 057F: BSF 03.5
1023 0580: MOVWF 07 1023 0580: MOVWF 07
1024 .................... I2C_Write(SHT25_ADDR); 1024 .................... I2C_Write(SHT25_ADDR);
1025 0581: MOVLW 80 1025 0581: MOVLW 80
1026 0582: BCF 03.5 1026 0582: BCF 03.5
1027 0583: MOVWF 3B 1027 0583: MOVWF 4E
1028 0584: CALL 078 1028 0584: CALL 078
1029 .................... I2C_write(0xE3); 1029 .................... I2C_write(0xE3);
1030 0585: MOVLW E3 1030 0585: MOVLW E3
1031 0586: MOVWF 3B 1031 0586: MOVWF 4E
1032 0587: CALL 078 1032 0587: CALL 078
1033 .................... i2c_stop(); 1033 .................... i2c_stop();
1034 0588: BCF 20.4 1034 0588: BCF 20.4
1035 0589: MOVF 20,W 1035 0589: MOVF 20,W
1036 058A: BSF 03.5 1036 058A: BSF 03.5
1037 058B: MOVWF 07 1037 058B: MOVWF 07
1038 058C: NOP 1038 058C: NOP
1039 058D: BCF 03.5 1039 058D: BCF 03.5
1040 058E: BSF 20.3 1040 058E: BSF 20.3
1041 058F: MOVF 20,W 1041 058F: MOVF 20,W
1042 0590: BSF 03.5 1042 0590: BSF 03.5
1043 0591: MOVWF 07 1043 0591: MOVWF 07
1044 0592: BCF 03.5 1044 0592: BCF 03.5
1045 0593: BTFSS 07.3 1045 0593: BTFSS 07.3
1046 0594: GOTO 593 1046 0594: GOTO 593
1047 0595: NOP 1047 0595: NOP
1048 0596: GOTO 597 1048 0596: GOTO 597
1049 0597: NOP 1049 0597: NOP
1050 0598: BSF 20.4 1050 0598: BSF 20.4
1051 0599: MOVF 20,W 1051 0599: MOVF 20,W
1052 059A: BSF 03.5 1052 059A: BSF 03.5
1053 059B: MOVWF 07 1053 059B: MOVWF 07
1054 059C: NOP 1054 059C: NOP
1055 .................... 1055 ....................
1056 .................... delay_ms(100); 1056 .................... delay_ms(100);
1057 059D: MOVLW 64 1057 059D: MOVLW 64
1058 059E: BCF 03.5 1058 059E: BCF 03.5
1059 059F: MOVWF 43 1059 059F: MOVWF 4B
1060 05A0: CALL 0FB 1060 05A0: CALL 0FB
1061 .................... 1061 ....................
1062 .................... i2c_start(); 1062 .................... i2c_start();
1063 05A1: BSF 20.4 1063 05A1: BSF 20.4
1064 05A2: MOVF 20,W 1064 05A2: MOVF 20,W
1065 05A3: BSF 03.5 1065 05A3: BSF 03.5
1066 05A4: MOVWF 07 1066 05A4: MOVWF 07
1067 05A5: NOP 1067 05A5: NOP
1068 05A6: BCF 03.5 1068 05A6: BCF 03.5
1069 05A7: BSF 20.3 1069 05A7: BSF 20.3
1070 05A8: MOVF 20,W 1070 05A8: MOVF 20,W
1071 05A9: BSF 03.5 1071 05A9: BSF 03.5
1072 05AA: MOVWF 07 1072 05AA: MOVWF 07
1073 05AB: NOP 1073 05AB: NOP
1074 05AC: BCF 03.5 1074 05AC: BCF 03.5
1075 05AD: BCF 07.4 1075 05AD: BCF 07.4
1076 05AE: BCF 20.4 1076 05AE: BCF 20.4
1077 05AF: MOVF 20,W 1077 05AF: MOVF 20,W
1078 05B0: BSF 03.5 1078 05B0: BSF 03.5
1079 05B1: MOVWF 07 1079 05B1: MOVWF 07
1080 05B2: NOP 1080 05B2: NOP
1081 05B3: BCF 03.5 1081 05B3: BCF 03.5
1082 05B4: BCF 07.3 1082 05B4: BCF 07.3
1083 05B5: BCF 20.3 1083 05B5: BCF 20.3
1084 05B6: MOVF 20,W 1084 05B6: MOVF 20,W
1085 05B7: BSF 03.5 1085 05B7: BSF 03.5
1086 05B8: MOVWF 07 1086 05B8: MOVWF 07
1087 .................... I2C_Write(SHT25_ADDR+1); 1087 .................... I2C_Write(SHT25_ADDR+1);
1088 05B9: MOVLW 81 1088 05B9: MOVLW 81
1089 05BA: BCF 03.5 1089 05BA: BCF 03.5
1090 05BB: MOVWF 3B 1090 05BB: MOVWF 4E
1091 05BC: CALL 078 1091 05BC: CALL 078
1092 .................... MSB=i2c_read(1); 1092 .................... MSB=i2c_read(1);
1093 05BD: MOVLW 01 1093 05BD: MOVLW 01
1094 05BE: MOVWF 77 1094 05BE: MOVWF 77
1095 05BF: CALL 285 1095 05BF: CALL 285
1096 05C0: MOVF 78,W 1096 05C0: MOVF 78,W
1097 05C1: MOVWF 35 1097 05C1: MOVWF 3D
1098 .................... LSB=i2c_read(1); 1098 .................... LSB=i2c_read(1);
1099 05C2: MOVLW 01 1099 05C2: MOVLW 01
1100 05C3: MOVWF 77 1100 05C3: MOVWF 77
1101 05C4: CALL 285 1101 05C4: CALL 285
1102 05C5: MOVF 78,W 1102 05C5: MOVF 78,W
1103 05C6: MOVWF 36 1103 05C6: MOVWF 3E
1104 .................... Check=i2c_read(0); 1104 .................... Check=i2c_read(0);
1105 05C7: CLRF 77 1105 05C7: CLRF 77
1106 05C8: CALL 285 1106 05C8: CALL 285
1107 05C9: MOVF 78,W 1107 05C9: MOVF 78,W
1108 05CA: MOVWF 37 1108 05CA: MOVWF 3F
1109 .................... i2c_stop(); 1109 .................... i2c_stop();
1110 05CB: BCF 20.4 1110 05CB: BCF 20.4
1111 05CC: MOVF 20,W 1111 05CC: MOVF 20,W
1112 05CD: BSF 03.5 1112 05CD: BSF 03.5
1113 05CE: MOVWF 07 1113 05CE: MOVWF 07
1114 05CF: NOP 1114 05CF: NOP
1115 05D0: BCF 03.5 1115 05D0: BCF 03.5
1116 05D1: BSF 20.3 1116 05D1: BSF 20.3
1117 05D2: MOVF 20,W 1117 05D2: MOVF 20,W
1118 05D3: BSF 03.5 1118 05D3: BSF 03.5
1119 05D4: MOVWF 07 1119 05D4: MOVWF 07
1120 05D5: BCF 03.5 1120 05D5: BCF 03.5
1121 05D6: BTFSS 07.3 1121 05D6: BTFSS 07.3
1122 05D7: GOTO 5D6 1122 05D7: GOTO 5D6
1123 05D8: NOP 1123 05D8: NOP
1124 05D9: GOTO 5DA 1124 05D9: GOTO 5DA
1125 05DA: NOP 1125 05DA: NOP
1126 05DB: BSF 20.4 1126 05DB: BSF 20.4
1127 05DC: MOVF 20,W 1127 05DC: MOVF 20,W
1128 05DD: BSF 03.5 1128 05DD: BSF 03.5
1129 05DE: MOVWF 07 1129 05DE: MOVWF 07
1130 05DF: NOP 1130 05DF: NOP
1131 .................... 1131 ....................
1132 .................... LSB = LSB >> 2; // trow out status bits 1132 .................... LSB = LSB >> 2; // trow out status bits
1133 05E0: BCF 03.5 1133 05E0: BCF 03.5
1134 05E1: RRF 36,F 1134 05E1: RRF 3E,F
1135 05E2: RRF 36,F 1135 05E2: RRF 3E,F
1136 05E3: MOVLW 3F 1136 05E3: MOVLW 3F
1137 05E4: ANDWF 36,F 1137 05E4: ANDWF 3E,F
1138 .................... 1138 ....................
1139 .................... data = (((unsigned int16) MSB << 8) + (LSB << 4)); 1139 .................... data = (((unsigned int16) MSB << 8) + (LSB << 4));
1140 05E5: CLRF 3B 1140 05E5: CLRF 43
1141 05E6: MOVF 35,W 1141 05E6: MOVF 3D,W
1142 05E7: MOVWF 3A 1142 05E7: MOVWF 42
1143 05E8: MOVWF 3B 1143 05E8: MOVWF 43
1144 05E9: CLRF 3A 1144 05E9: CLRF 42
1145 05EA: SWAPF 36,W 1145 05EA: SWAPF 3E,W
1146 05EB: MOVWF 77 1146 05EB: MOVWF 77
1147 05EC: MOVLW F0 1147 05EC: MOVLW F0
1148 05ED: ANDWF 77,F 1148 05ED: ANDWF 77,F
1149 05EE: MOVF 77,W 1149 05EE: MOVF 77,W
1150 05EF: ADDWF 3A,W 1150 05EF: ADDWF 42,W
1151 05F0: MOVWF 38 1151 05F0: MOVWF 40
1152 05F1: MOVF 3B,W 1152 05F1: MOVF 43,W
1153 05F2: MOVWF 39 1153 05F2: MOVWF 41
1154 05F3: BTFSC 03.0 1154 05F3: BTFSC 03.0
1155 05F4: INCF 39,F 1155 05F4: INCF 41,F
1156 .................... return(-46.85 + 175.72*((float)data/0xFFFF)); 1156 .................... return(-46.85 + 175.72*((float)data/0xFFFF));
1157 05F5: MOVF 39,W 1157 05F5: MOVF 41,W
1158 05F6: MOVWF 3B 1158 05F6: MOVWF 4E
1159 05F7: MOVF 38,W 1159 05F7: MOVF 40,W
1160 05F8: MOVWF 3A 1160 05F8: MOVWF 4D
1161 05F9: CALL 2CA 1161 05F9: CALL 2CA
1162 05FA: MOVF 77,W 1162 05FA: MOVF 77,W
1163 05FB: MOVWF 3A 1163 05FB: MOVWF 42
1164 05FC: MOVF 78,W 1164 05FC: MOVF 78,W
1165 05FD: MOVWF 3B 1165 05FD: MOVWF 43
1166 05FE: MOVF 79,W 1166 05FE: MOVF 79,W
1167 05FF: MOVWF 3C 1167 05FF: MOVWF 44
1168 0600: MOVF 7A,W 1168 0600: MOVF 7A,W
1169 0601: MOVWF 3D 1169 0601: MOVWF 45
1170 0602: MOVWF 41 1170 0602: MOVWF 54
1171 0603: MOVF 79,W 1171 0603: MOVF 79,W
1172 0604: MOVWF 40 1172 0604: MOVWF 53
1173 0605: MOVF 78,W 1173 0605: MOVF 78,W
1174 0606: MOVWF 3F 1174 0606: MOVWF 52
1175 0607: MOVF 77,W 1175 0607: MOVF 77,W
1176 0608: MOVWF 3E 1176 0608: MOVWF 51
1177 0609: CLRF 45 1177 0609: CLRF 58
1178 060A: MOVLW FF 1178 060A: MOVLW FF
1179 060B: MOVWF 44 1179 060B: MOVWF 57
1180 060C: MOVLW 7F 1180 060C: MOVLW 7F
1181 060D: MOVWF 43 1181 060D: MOVWF 56
1182 060E: MOVLW 8E 1182 060E: MOVLW 8E
1183 060F: MOVWF 42 1183 060F: MOVWF 55
1184 0610: CALL 2E7 1184 0610: CALL 2E7
1185 0611: MOVLW 52 1185 0611: MOVLW 52
1186 0612: MOVWF 45 1186 0612: MOVWF 4D
1187 0613: MOVLW B8 1187 0613: MOVLW B8
1188 0614: MOVWF 44 1188 0614: MOVWF 4C
1189 0615: MOVLW 2F 1189 0615: MOVLW 2F
1190 0616: MOVWF 43 1190 0616: MOVWF 4B
1191 0617: MOVLW 86 1191 0617: MOVLW 86
1192 0618: MOVWF 42 1192 0618: MOVWF 4A
1193 0619: MOVF 7A,W 1193 0619: MOVF 7A,W
1194 061A: MOVWF 49 1194 061A: MOVWF 51
1195 061B: MOVF 79,W 1195 061B: MOVF 79,W
1196 061C: MOVWF 48 1196 061C: MOVWF 50
1197 061D: MOVF 78,W 1197 061D: MOVF 78,W
1198 061E: MOVWF 47 1198 061E: MOVWF 4F
1199 061F: MOVF 77,W 1199 061F: MOVF 77,W
1200 0620: MOVWF 46 1200 0620: MOVWF 4E
1201 0621: CALL 3B1 1201 0621: CALL 3B1
1202 0622: BCF 03.1 1202 0622: BCF 03.1
1203 0623: MOVLW 66 1203 0623: MOVLW 66
1204 0624: MOVWF 3D 1204 0624: MOVWF 56
1205 0625: MOVWF 3C 1205 0625: MOVWF 55
1206 0626: MOVLW BB 1206 0626: MOVLW BB
1207 0627: MOVWF 3B 1207 0627: MOVWF 54
1208 0628: MOVLW 84 1208 0628: MOVLW 84
1209 0629: MOVWF 3A 1209 0629: MOVWF 53
1210 062A: MOVF 7A,W 1210 062A: MOVF 7A,W
1211 062B: MOVWF 41 1211 062B: MOVWF 5A
1212 062C: MOVF 79,W 1212 062C: MOVF 79,W
1213 062D: MOVWF 40 1213 062D: MOVWF 59
1214 062E: MOVF 78,W 1214 062E: MOVF 78,W
1215 062F: MOVWF 3F 1215 062F: MOVWF 58
1216 0630: MOVF 77,W 1216 0630: MOVF 77,W
1217 0631: MOVWF 3E 1217 0631: MOVWF 57
1218 0632: CALL 426 1218 0632: CALL 426
1219 .................... } 1219 .................... }
1220 0633: BSF 0A.3 1220 0633: BSF 0A.3
1221 0634: BCF 0A.4 1221 0634: BCF 0A.4
1222 0635: GOTO 38B (RETURN) 1222 0635: GOTO 5B9 (RETURN)
1223 .................... 1223 ....................
1224 .................... float SHT25_get_hum() 1224 .................... float SHT25_get_hum()
1225 .................... { 1225 .................... {
1226 .................... unsigned int8 MSB, LSB, Check; 1226 .................... unsigned int8 MSB, LSB, Check;
1227 .................... unsigned int16 data; 1227 .................... unsigned int16 data;
1228 .................... 1228 ....................
1229 .................... i2c_start(); //RH 1229 .................... i2c_start(); //RH
1230 0636: BSF 20.4 1230 0636: BSF 20.4
1231 0637: MOVF 20,W 1231 0637: MOVF 20,W
1232 0638: BSF 03.5 1232 0638: BSF 03.5
1233 0639: MOVWF 07 1233 0639: MOVWF 07
1234 063A: NOP 1234 063A: NOP
1235 063B: BCF 03.5 1235 063B: BCF 03.5
1236 063C: BSF 20.3 1236 063C: BSF 20.3
1237 063D: MOVF 20,W 1237 063D: MOVF 20,W
1238 063E: BSF 03.5 1238 063E: BSF 03.5
1239 063F: MOVWF 07 1239 063F: MOVWF 07
1240 0640: NOP 1240 0640: NOP
1241 0641: BCF 03.5 1241 0641: BCF 03.5
1242 0642: BCF 07.4 1242 0642: BCF 07.4
1243 0643: BCF 20.4 1243 0643: BCF 20.4
1244 0644: MOVF 20,W 1244 0644: MOVF 20,W
1245 0645: BSF 03.5 1245 0645: BSF 03.5
1246 0646: MOVWF 07 1246 0646: MOVWF 07
1247 0647: NOP 1247 0647: NOP
1248 0648: BCF 03.5 1248 0648: BCF 03.5
1249 0649: BCF 07.3 1249 0649: BCF 07.3
1250 064A: BCF 20.3 1250 064A: BCF 20.3
1251 064B: MOVF 20,W 1251 064B: MOVF 20,W
1252 064C: BSF 03.5 1252 064C: BSF 03.5
1253 064D: MOVWF 07 1253 064D: MOVWF 07
1254 .................... I2C_Write(SHT25_ADDR); 1254 .................... I2C_Write(SHT25_ADDR);
1255 064E: MOVLW 80 1255 064E: MOVLW 80
1256 064F: BCF 03.5 1256 064F: BCF 03.5
1257 0650: MOVWF 3B 1257 0650: MOVWF 4E
1258 0651: CALL 078 1258 0651: CALL 078
1259 .................... I2C_write(0xE5); 1259 .................... I2C_write(0xE5);
1260 0652: MOVLW E5 1260 0652: MOVLW E5
1261 0653: MOVWF 3B 1261 0653: MOVWF 4E
1262 0654: CALL 078 1262 0654: CALL 078
1263 .................... 1263 ....................
1264 .................... delay_ms(100); 1264 .................... delay_ms(100);
1265 0655: MOVLW 64 1265 0655: MOVLW 64
1266 0656: MOVWF 43 1266 0656: MOVWF 4B
1267 0657: CALL 0FB 1267 0657: CALL 0FB
1268 .................... 1268 ....................
1269 .................... i2c_start(); 1269 .................... i2c_start();
1270 0658: BSF 20.4 1270 0658: BSF 20.4
1271 0659: MOVF 20,W 1271 0659: MOVF 20,W
1272 065A: BSF 03.5 1272 065A: BSF 03.5
1273 065B: MOVWF 07 1273 065B: MOVWF 07
1274 065C: NOP 1274 065C: NOP
1275 065D: BCF 03.5 1275 065D: BCF 03.5
1276 065E: BSF 20.3 1276 065E: BSF 20.3
1277 065F: MOVF 20,W 1277 065F: MOVF 20,W
1278 0660: BSF 03.5 1278 0660: BSF 03.5
1279 0661: MOVWF 07 1279 0661: MOVWF 07
1280 0662: NOP 1280 0662: NOP
1281 0663: BCF 03.5 1281 0663: BCF 03.5
1282 0664: BTFSS 07.3 1282 0664: BTFSS 07.3
1283 0665: GOTO 664 1283 0665: GOTO 664
1284 0666: BCF 07.4 1284 0666: BCF 07.4
1285 0667: BCF 20.4 1285 0667: BCF 20.4
1286 0668: MOVF 20,W 1286 0668: MOVF 20,W
1287 0669: BSF 03.5 1287 0669: BSF 03.5
1288 066A: MOVWF 07 1288 066A: MOVWF 07
1289 066B: NOP 1289 066B: NOP
1290 066C: BCF 03.5 1290 066C: BCF 03.5
1291 066D: BCF 07.3 1291 066D: BCF 07.3
1292 066E: BCF 20.3 1292 066E: BCF 20.3
1293 066F: MOVF 20,W 1293 066F: MOVF 20,W
1294 0670: BSF 03.5 1294 0670: BSF 03.5
1295 0671: MOVWF 07 1295 0671: MOVWF 07
1296 .................... I2C_Write(SHT25_ADDR+1); 1296 .................... I2C_Write(SHT25_ADDR+1);
1297 0672: MOVLW 81 1297 0672: MOVLW 81
1298 0673: BCF 03.5 1298 0673: BCF 03.5
1299 0674: MOVWF 3B 1299 0674: MOVWF 4E
1300 0675: CALL 078 1300 0675: CALL 078
1301 .................... MSB=i2c_read(1); 1301 .................... MSB=i2c_read(1);
1302 0676: MOVLW 01 1302 0676: MOVLW 01
1303 0677: MOVWF 77 1303 0677: MOVWF 77
1304 0678: CALL 285 1304 0678: CALL 285
1305 0679: MOVF 78,W 1305 0679: MOVF 78,W
1306 067A: MOVWF 35 1306 067A: MOVWF 3D
1307 .................... LSB=i2c_read(1); 1307 .................... LSB=i2c_read(1);
1308 067B: MOVLW 01 1308 067B: MOVLW 01
1309 067C: MOVWF 77 1309 067C: MOVWF 77
1310 067D: CALL 285 1310 067D: CALL 285
1311 067E: MOVF 78,W 1311 067E: MOVF 78,W
1312 067F: MOVWF 36 1312 067F: MOVWF 3E
1313 .................... Check=i2c_read(0); 1313 .................... Check=i2c_read(0);
1314 0680: CLRF 77 1314 0680: CLRF 77
1315 0681: CALL 285 1315 0681: CALL 285
1316 0682: MOVF 78,W 1316 0682: MOVF 78,W
1317 0683: MOVWF 37 1317 0683: MOVWF 3F
1318 .................... i2c_stop(); 1318 .................... i2c_stop();
1319 0684: BCF 20.4 1319 0684: BCF 20.4
1320 0685: MOVF 20,W 1320 0685: MOVF 20,W
1321 0686: BSF 03.5 1321 0686: BSF 03.5
1322 0687: MOVWF 07 1322 0687: MOVWF 07
1323 0688: NOP 1323 0688: NOP
1324 0689: BCF 03.5 1324 0689: BCF 03.5
1325 068A: BSF 20.3 1325 068A: BSF 20.3
1326 068B: MOVF 20,W 1326 068B: MOVF 20,W
1327 068C: BSF 03.5 1327 068C: BSF 03.5
1328 068D: MOVWF 07 1328 068D: MOVWF 07
1329 068E: BCF 03.5 1329 068E: BCF 03.5
1330 068F: BTFSS 07.3 1330 068F: BTFSS 07.3
1331 0690: GOTO 68F 1331 0690: GOTO 68F
1332 0691: NOP 1332 0691: NOP
1333 0692: GOTO 693 1333 0692: GOTO 693
1334 0693: NOP 1334 0693: NOP
1335 0694: BSF 20.4 1335 0694: BSF 20.4
1336 0695: MOVF 20,W 1336 0695: MOVF 20,W
1337 0696: BSF 03.5 1337 0696: BSF 03.5
1338 0697: MOVWF 07 1338 0697: MOVWF 07
1339 0698: NOP 1339 0698: NOP
1340 .................... 1340 ....................
1341 .................... LSB = LSB >> 2; // trow out status bits 1341 .................... LSB = LSB >> 2; // trow out status bits
1342 0699: BCF 03.5 1342 0699: BCF 03.5
1343 069A: RRF 36,F 1343 069A: RRF 3E,F
1344 069B: RRF 36,F 1344 069B: RRF 3E,F
1345 069C: MOVLW 3F 1345 069C: MOVLW 3F
1346 069D: ANDWF 36,F 1346 069D: ANDWF 3E,F
1347 .................... 1347 ....................
1348 .................... data = (((unsigned int16) MSB << 8) + (LSB << 4) ); 1348 .................... data = (((unsigned int16) MSB << 8) + (LSB << 4) );
1349 069E: CLRF 3B 1349 069E: CLRF 43
1350 069F: MOVF 35,W 1350 069F: MOVF 3D,W
1351 06A0: MOVWF 3A 1351 06A0: MOVWF 42
1352 06A1: MOVWF 3B 1352 06A1: MOVWF 43
1353 06A2: CLRF 3A 1353 06A2: CLRF 42
1354 06A3: SWAPF 36,W 1354 06A3: SWAPF 3E,W
1355 06A4: MOVWF 77 1355 06A4: MOVWF 77
1356 06A5: MOVLW F0 1356 06A5: MOVLW F0
1357 06A6: ANDWF 77,F 1357 06A6: ANDWF 77,F
1358 06A7: MOVF 77,W 1358 06A7: MOVF 77,W
1359 06A8: ADDWF 3A,W 1359 06A8: ADDWF 42,W
1360 06A9: MOVWF 38 1360 06A9: MOVWF 40
1361 06AA: MOVF 3B,W 1361 06AA: MOVF 43,W
1362 06AB: MOVWF 39 1362 06AB: MOVWF 41
1363 06AC: BTFSC 03.0 1363 06AC: BTFSC 03.0
1364 06AD: INCF 39,F 1364 06AD: INCF 41,F
1365 .................... return( -6.0 + 125.0*((float)data/0xFFFF)); 1365 .................... return( -6.0 + 125.0*((float)data/0xFFFF));
1366 06AE: MOVF 39,W 1366 06AE: MOVF 41,W
1367 06AF: MOVWF 3B 1367 06AF: MOVWF 4E
1368 06B0: MOVF 38,W 1368 06B0: MOVF 40,W
1369 06B1: MOVWF 3A 1369 06B1: MOVWF 4D
1370 06B2: CALL 2CA 1370 06B2: CALL 2CA
1371 06B3: MOVF 77,W 1371 06B3: MOVF 77,W
1372 06B4: MOVWF 3A 1372 06B4: MOVWF 42
1373 06B5: MOVF 78,W 1373 06B5: MOVF 78,W
1374 06B6: MOVWF 3B 1374 06B6: MOVWF 43
1375 06B7: MOVF 79,W 1375 06B7: MOVF 79,W
1376 06B8: MOVWF 3C 1376 06B8: MOVWF 44
1377 06B9: MOVF 7A,W 1377 06B9: MOVF 7A,W
1378 06BA: MOVWF 3D 1378 06BA: MOVWF 45
1379 06BB: MOVWF 41 1379 06BB: MOVWF 54
1380 06BC: MOVF 79,W 1380 06BC: MOVF 79,W
1381 06BD: MOVWF 40 1381 06BD: MOVWF 53
1382 06BE: MOVF 78,W 1382 06BE: MOVF 78,W
1383 06BF: MOVWF 3F 1383 06BF: MOVWF 52
1384 06C0: MOVF 77,W 1384 06C0: MOVF 77,W
1385 06C1: MOVWF 3E 1385 06C1: MOVWF 51
1386 06C2: CLRF 45 1386 06C2: CLRF 58
1387 06C3: MOVLW FF 1387 06C3: MOVLW FF
1388 06C4: MOVWF 44 1388 06C4: MOVWF 57
1389 06C5: MOVLW 7F 1389 06C5: MOVLW 7F
1390 06C6: MOVWF 43 1390 06C6: MOVWF 56
1391 06C7: MOVLW 8E 1391 06C7: MOVLW 8E
1392 06C8: MOVWF 42 1392 06C8: MOVWF 55
1393 06C9: CALL 2E7 1393 06C9: CALL 2E7
1394 06CA: CLRF 45 1394 06CA: CLRF 4D
1395 06CB: CLRF 44 1395 06CB: CLRF 4C
1396 06CC: MOVLW 7A 1396 06CC: MOVLW 7A
1397 06CD: MOVWF 43 1397 06CD: MOVWF 4B
1398 06CE: MOVLW 85 1398 06CE: MOVLW 85
1399 06CF: MOVWF 42 1399 06CF: MOVWF 4A
1400 06D0: MOVF 7A,W 1400 06D0: MOVF 7A,W
1401 06D1: MOVWF 49 1401 06D1: MOVWF 51
1402 06D2: MOVF 79,W 1402 06D2: MOVF 79,W
1403 06D3: MOVWF 48 1403 06D3: MOVWF 50
1404 06D4: MOVF 78,W 1404 06D4: MOVF 78,W
1405 06D5: MOVWF 47 1405 06D5: MOVWF 4F
1406 06D6: MOVF 77,W 1406 06D6: MOVF 77,W
1407 06D7: MOVWF 46 1407 06D7: MOVWF 4E
1408 06D8: CALL 3B1 1408 06D8: CALL 3B1
1409 06D9: BCF 03.1 1409 06D9: BCF 03.1
1410 06DA: CLRF 3D 1410 06DA: CLRF 56
1411 06DB: CLRF 3C 1411 06DB: CLRF 55
1412 06DC: MOVLW C0 1412 06DC: MOVLW C0
1413 06DD: MOVWF 3B 1413 06DD: MOVWF 54
1414 06DE: MOVLW 81 1414 06DE: MOVLW 81
1415 06DF: MOVWF 3A 1415 06DF: MOVWF 53
1416 06E0: MOVF 7A,W 1416 06E0: MOVF 7A,W
1417 06E1: MOVWF 41 1417 06E1: MOVWF 5A
1418 06E2: MOVF 79,W 1418 06E2: MOVF 79,W
1419 06E3: MOVWF 40 1419 06E3: MOVWF 59
1420 06E4: MOVF 78,W 1420 06E4: MOVF 78,W
1421 06E5: MOVWF 3F 1421 06E5: MOVWF 58
1422 06E6: MOVF 77,W 1422 06E6: MOVF 77,W
1423 06E7: MOVWF 3E 1423 06E7: MOVWF 57
1424 06E8: CALL 426 1424 06E8: CALL 426
1425 .................... } 1425 .................... }
1426 06E9: BSF 0A.3 1426 06E9: BSF 0A.3
1427 06EA: BCF 0A.4 1427 06EA: BCF 0A.4
1428 06EB: GOTO 396 (RETURN) 1428 06EB: GOTO 5C4 (RETURN)
1429 .................... 1429 ....................
1430 .................... 1430 ....................
1431 .................... 1431 ....................
1432 .................... 1432 ....................
1433 .................... #include "../LTS01.h" 1433 .................... #include "../LTS01.h"
1434 .................... //Adresa pro VDD, VDD, VDD W 0x9E R 0x9F 1434 .................... //Adresa pro VDD, VDD, VDD W 0x9E R 0x9F
1435 .................... //Adresa pro GND GND GND W 0x90 R 0x91 1435 .................... //Adresa pro GND GND GND W 0x90 R 0x91
1436 .................... 1436 ....................
1437 .................... #define LTS01A_address 0x90 1437 .................... #define LTS01A_address 0x90
1438 .................... 1438 ....................
1439 .................... #include "LTS01.c" 1439 .................... #include "LTS01.c"
1440 .................... float LTS01_get_temp() 1440 .................... float LTS01_get_temp()
1441 .................... { 1441 .................... {
1442 .................... unsigned int8 MSB; 1442 .................... unsigned int8 MSB;
1443 .................... unsigned int8 LSB; 1443 .................... unsigned int8 LSB;
1444 .................... signed int16 data; 1444 .................... signed int16 data;
1445 .................... 1445 ....................
1446 .................... i2c_start(); 1446 .................... i2c_start();
1447 06EC: BSF 20.4 1447 06EC: BSF 20.4
1448 06ED: MOVF 20,W 1448 06ED: MOVF 20,W
1449 06EE: BSF 03.5 1449 06EE: BSF 03.5
1450 06EF: MOVWF 07 1450 06EF: MOVWF 07
1451 06F0: NOP 1451 06F0: NOP
1452 06F1: BCF 03.5 1452 06F1: BCF 03.5
1453 06F2: BSF 20.3 1453 06F2: BSF 20.3
1454 06F3: MOVF 20,W 1454 06F3: MOVF 20,W
1455 06F4: BSF 03.5 1455 06F4: BSF 03.5
1456 06F5: MOVWF 07 1456 06F5: MOVWF 07
1457 06F6: NOP 1457 06F6: NOP
1458 06F7: BCF 03.5 1458 06F7: BCF 03.5
1459 06F8: BCF 07.4 1459 06F8: BCF 07.4
1460 06F9: BCF 20.4 1460 06F9: BCF 20.4
1461 06FA: MOVF 20,W 1461 06FA: MOVF 20,W
1462 06FB: BSF 03.5 1462 06FB: BSF 03.5
1463 06FC: MOVWF 07 1463 06FC: MOVWF 07
1464 06FD: NOP 1464 06FD: NOP
1465 06FE: BCF 03.5 1465 06FE: BCF 03.5
1466 06FF: BCF 07.3 1466 06FF: BCF 07.3
1467 0700: BCF 20.3 1467 0700: BCF 20.3
1468 0701: MOVF 20,W 1468 0701: MOVF 20,W
1469 0702: BSF 03.5 1469 0702: BSF 03.5
1470 0703: MOVWF 07 1470 0703: MOVWF 07
1471 .................... I2C_Write(LTS01A_address); 1471 .................... I2C_Write(LTS01A_address);
1472 0704: MOVLW 90 1472 0704: MOVLW 90
1473 0705: BCF 03.5 1473 0705: BCF 03.5
1474 0706: MOVWF 3B 1474 0706: MOVWF 4E
1475 0707: CALL 078 1475 0707: CALL 078
1476 .................... I2C_write(0x00); 1476 .................... I2C_write(0x00);
1477 0708: CLRF 3B 1477 0708: CLRF 4E
1478 0709: CALL 078 1478 0709: CALL 078
1479 .................... i2c_stop(); 1479 .................... i2c_stop();
1480 070A: BCF 20.4 1480 070A: BCF 20.4
1481 070B: MOVF 20,W 1481 070B: MOVF 20,W
1482 070C: BSF 03.5 1482 070C: BSF 03.5
1483 070D: MOVWF 07 1483 070D: MOVWF 07
1484 070E: NOP 1484 070E: NOP
1485 070F: BCF 03.5 1485 070F: BCF 03.5
1486 0710: BSF 20.3 1486 0710: BSF 20.3
1487 0711: MOVF 20,W 1487 0711: MOVF 20,W
1488 0712: BSF 03.5 1488 0712: BSF 03.5
1489 0713: MOVWF 07 1489 0713: MOVWF 07
1490 0714: BCF 03.5 1490 0714: BCF 03.5
1491 0715: BTFSS 07.3 1491 0715: BTFSS 07.3
1492 0716: GOTO 715 1492 0716: GOTO 715
1493 0717: NOP 1493 0717: NOP
1494 0718: GOTO 719 1494 0718: GOTO 719
1495 0719: NOP 1495 0719: NOP
1496 071A: BSF 20.4 1496 071A: BSF 20.4
1497 071B: MOVF 20,W 1497 071B: MOVF 20,W
1498 071C: BSF 03.5 1498 071C: BSF 03.5
1499 071D: MOVWF 07 1499 071D: MOVWF 07
1500 071E: NOP 1500 071E: NOP
1501 .................... i2c_start(); 1501 .................... i2c_start();
1502 071F: BCF 03.5 1502 071F: BCF 03.5
1503 0720: BSF 20.4 1503 0720: BSF 20.4
1504 0721: MOVF 20,W 1504 0721: MOVF 20,W
1505 0722: BSF 03.5 1505 0722: BSF 03.5
1506 0723: MOVWF 07 1506 0723: MOVWF 07
1507 0724: NOP 1507 0724: NOP
1508 0725: BCF 03.5 1508 0725: BCF 03.5
1509 0726: BSF 20.3 1509 0726: BSF 20.3
1510 0727: MOVF 20,W 1510 0727: MOVF 20,W
1511 0728: BSF 03.5 1511 0728: BSF 03.5
1512 0729: MOVWF 07 1512 0729: MOVWF 07
1513 072A: NOP 1513 072A: NOP
1514 072B: BCF 03.5 1514 072B: BCF 03.5
1515 072C: BCF 07.4 1515 072C: BCF 07.4
1516 072D: BCF 20.4 1516 072D: BCF 20.4
1517 072E: MOVF 20,W 1517 072E: MOVF 20,W
1518 072F: BSF 03.5 1518 072F: BSF 03.5
1519 0730: MOVWF 07 1519 0730: MOVWF 07
1520 0731: NOP 1520 0731: NOP
1521 0732: BCF 03.5 1521 0732: BCF 03.5
1522 0733: BCF 07.3 1522 0733: BCF 07.3
1523 0734: BCF 20.3 1523 0734: BCF 20.3
1524 0735: MOVF 20,W 1524 0735: MOVF 20,W
1525 0736: BSF 03.5 1525 0736: BSF 03.5
1526 0737: MOVWF 07 1526 0737: MOVWF 07
1527 .................... I2C_Write(LTS01A_address+1); 1527 .................... I2C_Write(LTS01A_address+1);
1528 0738: MOVLW 91 1528 0738: MOVLW 91
1529 0739: BCF 03.5 1529 0739: BCF 03.5
1530 073A: MOVWF 3B 1530 073A: MOVWF 4E
1531 073B: CALL 078 1531 073B: CALL 078
1532 .................... MSB=i2c_read(1); 1532 .................... MSB=i2c_read(1);
1533 073C: MOVLW 01 1533 073C: MOVLW 01
1534 073D: MOVWF 77 1534 073D: MOVWF 77
1535 073E: CALL 285 1535 073E: CALL 285
1536 073F: MOVF 78,W 1536 073F: MOVF 78,W
1537 0740: MOVWF 35 1537 0740: MOVWF 3D
1538 .................... LSB=i2c_read(0); 1538 .................... LSB=i2c_read(0);
1539 0741: CLRF 77 1539 0741: CLRF 77
1540 0742: CALL 285 1540 0742: CALL 285
1541 0743: MOVF 78,W 1541 0743: MOVF 78,W
1542 0744: MOVWF 36 1542 0744: MOVWF 3E
1543 .................... i2c_stop(); 1543 .................... i2c_stop();
1544 0745: BCF 20.4 1544 0745: BCF 20.4
1545 0746: MOVF 20,W 1545 0746: MOVF 20,W
1546 0747: BSF 03.5 1546 0747: BSF 03.5
1547 0748: MOVWF 07 1547 0748: MOVWF 07
1548 0749: NOP 1548 0749: NOP
1549 074A: BCF 03.5 1549 074A: BCF 03.5
1550 074B: BSF 20.3 1550 074B: BSF 20.3
1551 074C: MOVF 20,W 1551 074C: MOVF 20,W
1552 074D: BSF 03.5 1552 074D: BSF 03.5
1553 074E: MOVWF 07 1553 074E: MOVWF 07
1554 074F: BCF 03.5 1554 074F: BCF 03.5
1555 0750: BTFSS 07.3 1555 0750: BTFSS 07.3
1556 0751: GOTO 750 1556 0751: GOTO 750
1557 0752: NOP 1557 0752: NOP
1558 0753: GOTO 754 1558 0753: GOTO 754
1559 0754: NOP 1559 0754: NOP
1560 0755: BSF 20.4 1560 0755: BSF 20.4
1561 0756: MOVF 20,W 1561 0756: MOVF 20,W
1562 0757: BSF 03.5 1562 0757: BSF 03.5
1563 0758: MOVWF 07 1563 0758: MOVWF 07
1564 0759: NOP 1564 0759: NOP
1565 .................... 1565 ....................
1566 .................... data = MAKE16(MSB,LSB); 1566 .................... data = MAKE16(MSB,LSB);
1567 075A: BCF 03.5 1567 075A: BCF 03.5
1568 075B: MOVF 35,W 1568 075B: MOVF 3D,W
1569 075C: MOVWF 38 1569 075C: MOVWF 40
1570 075D: MOVF 36,W 1570 075D: MOVF 3E,W
1571 075E: MOVWF 37 1571 075E: MOVWF 3F
1572 .................... 1572 ....................
1573 .................... return (data * 0.00390625 ); 1573 .................... return (data * 0.00390625 );
1574 075F: MOVF 38,W 1574 075F: MOVF 40,W
1575 0760: MOVWF 3A 1575 0760: MOVWF 42
1576 0761: MOVF 37,W 1576 0761: MOVF 3F,W
1577 0762: MOVWF 39 1577 0762: MOVWF 41
1578 0763: MOVF 3A,W 1578 0763: MOVF 42,W
1579 0764: MOVWF 3C 1579 0764: MOVWF 44
1580 0765: MOVF 39,W 1580 0765: MOVF 41,W
1581 0766: MOVWF 3B 1581 0766: MOVWF 43
1582 * 1582 *
1583 078B: MOVF 7A,W 1583 078B: MOVF 7A,W
1584 078C: MOVWF 45 1584 078C: MOVWF 4D
1585 078D: MOVF 79,W 1585 078D: MOVF 79,W
1586 078E: MOVWF 44 1586 078E: MOVWF 4C
1587 078F: MOVF 78,W 1587 078F: MOVF 78,W
1588 0790: MOVWF 43 1588 0790: MOVWF 4B
1589 0791: MOVF 77,W 1589 0791: MOVF 77,W
1590 0792: MOVWF 42 1590 0792: MOVWF 4A
1591 0793: CLRF 49 1591 0793: CLRF 51
1592 0794: CLRF 48 1592 0794: CLRF 50
1593 0795: CLRF 47 1593 0795: CLRF 4F
1594 0796: MOVLW 77 1594 0796: MOVLW 77
1595 0797: MOVWF 46 1595 0797: MOVWF 4E
1596 0798: CALL 3B1 1596 0798: CALL 3B1
1597 .................... 1597 ....................
1598 .................... } 1598 .................... }
1599 0799: BSF 0A.3 1599 0799: BSF 0A.3
1600 079A: BCF 0A.4 1600 079A: BCF 0A.4
1601 079B: GOTO 3A1 (RETURN) 1601 079B: GOTO 5CF (RETURN)
1602 .................... 1602 ....................
1603 .................... 1603 ....................
1604 .................... 1604 ....................
1605 .................... #include "./HMC5883L.h" 1605 .................... #include "./HMC5883L.h"
1606 .................... // i2c slave addresses 1606 .................... // i2c slave addresses
1607 .................... #define HMC5883L_WRT_ADDR 0x3C 1607 .................... #define HMC5883L_WRT_ADDR 0x3C
1608 .................... #define HMC5883L_READ_ADDR 0x3D 1608 .................... #define HMC5883L_READ_ADDR 0x3D
1609 .................... 1609 ....................
1610 .................... // Register addresses 1610 .................... // Register addresses
1611 .................... #define HMC5883L_CFG_A_REG 0x00 1611 .................... #define HMC5883L_CFG_A_REG 0x00
1612 .................... #define HMC5883L_CFG_B_REG 0x01 1612 .................... #define HMC5883L_CFG_B_REG 0x01
1613 .................... #define HMC5883L_MODE_REG 0x02 1613 .................... #define HMC5883L_MODE_REG 0x02
1614 .................... #define HMC5883L_X_MSB_REG 0x03 1614 .................... #define HMC5883L_X_MSB_REG 0x03
1615 .................... 1615 ....................
1616 .................... //Konstanty nastavujici rozsah 1616 .................... //Konstanty nastavujici rozsah
1617 .................... //pro void set_mag_roz (unsigned int8 h) 1617 .................... //pro void set_mag_roz (unsigned int8 h)
1618 .................... #define MAG_ROZ088 0x00 1618 .................... #define MAG_ROZ088 0x00
1619 .................... #define MAG_ROZ130 0x20 1619 .................... #define MAG_ROZ130 0x20
1620 .................... #define MAG_ROZ190 0x40 1620 .................... #define MAG_ROZ190 0x40
1621 .................... #define MAG_ROZ250 0x60 1621 .................... #define MAG_ROZ250 0x60
1622 .................... #define MAG_ROZ400 0x80 1622 .................... #define MAG_ROZ400 0x80
1623 .................... #define MAG_ROZ470 0xA0 1623 .................... #define MAG_ROZ470 0xA0
1624 .................... #define MAG_ROZ560 0xC0 1624 .................... #define MAG_ROZ560 0xC0
1625 .................... #define MAG_ROZ810 0xE0 1625 .................... #define MAG_ROZ810 0xE0
1626 .................... 1626 ....................
1627 .................... 1627 ....................
1628 .................... #include "HMC5883L.c" 1628 .................... #include "HMC5883L.c"
1629 .................... //------------------------------ 1629 .................... //------------------------------
1630 .................... // Low level routines 1630 .................... // Low level routines
1631 .................... //------------------------------ 1631 .................... //------------------------------
1632 .................... void hmc5883l_write_reg(int8 reg, int8 data) 1632 .................... void hmc5883l_write_reg(int8 reg, int8 data)
1633 .................... { 1633 .................... {
1634 .................... i2c_start(); 1634 .................... i2c_start();
1635 * 1635 *
1636 00C2: BSF 20.4 1636 00C2: BSF 20.4
1637 00C3: MOVF 20,W 1637 00C3: MOVF 20,W
1638 00C4: BSF 03.5 1638 00C4: BSF 03.5
1639 00C5: MOVWF 07 1639 00C5: MOVWF 07
1640 00C6: NOP 1640 00C6: NOP
1641 00C7: BCF 03.5 1641 00C7: BCF 03.5
1642 00C8: BSF 20.3 1642 00C8: BSF 20.3
1643 00C9: MOVF 20,W 1643 00C9: MOVF 20,W
1644 00CA: BSF 03.5 1644 00CA: BSF 03.5
1645 00CB: MOVWF 07 1645 00CB: MOVWF 07
1646 00CC: NOP 1646 00CC: NOP
1647 00CD: BCF 03.5 1647 00CD: BCF 03.5
1648 00CE: BCF 07.4 1648 00CE: BCF 07.4
1649 00CF: BCF 20.4 1649 00CF: BCF 20.4
1650 00D0: MOVF 20,W 1650 00D0: MOVF 20,W
1651 00D1: BSF 03.5 1651 00D1: BSF 03.5
1652 00D2: MOVWF 07 1652 00D2: MOVWF 07
1653 00D3: NOP 1653 00D3: NOP
1654 00D4: BCF 03.5 1654 00D4: BCF 03.5
1655 00D5: BCF 07.3 1655 00D5: BCF 07.3
1656 00D6: BCF 20.3 1656 00D6: BCF 20.3
1657 00D7: MOVF 20,W 1657 00D7: MOVF 20,W
1658 00D8: BSF 03.5 1658 00D8: BSF 03.5
1659 00D9: MOVWF 07 1659 00D9: MOVWF 07
1660 .................... i2c_write(HMC5883L_WRT_ADDR); 1660 .................... i2c_write(HMC5883L_WRT_ADDR);
1661 00DA: MOVLW 3C 1661 00DA: MOVLW 3C
1662 00DB: BCF 03.5 1662 00DB: BCF 03.5
1663 00DC: MOVWF 3B 1663 00DC: MOVWF 4E
1664 00DD: CALL 078 1664 00DD: CALL 078
1665 .................... i2c_write(reg); 1665 .................... i2c_write(reg);
1666 00DE: MOVF 35,W 1666 00DE: MOVF 3D,W
1667 00DF: MOVWF 3B 1667 00DF: MOVWF 4E
1668 00E0: CALL 078 1668 00E0: CALL 078
1669 .................... i2c_write(data); 1669 .................... i2c_write(data);
1670 00E1: MOVF 36,W 1670 00E1: MOVF 3E,W
1671 00E2: MOVWF 3B 1671 00E2: MOVWF 4E
1672 00E3: CALL 078 1672 00E3: CALL 078
1673 .................... i2c_stop(); 1673 .................... i2c_stop();
1674 00E4: BCF 20.4 1674 00E4: BCF 20.4
1675 00E5: MOVF 20,W 1675 00E5: MOVF 20,W
1676 00E6: BSF 03.5 1676 00E6: BSF 03.5
1677 00E7: MOVWF 07 1677 00E7: MOVWF 07
1678 00E8: NOP 1678 00E8: NOP
1679 00E9: BCF 03.5 1679 00E9: BCF 03.5
1680 00EA: BSF 20.3 1680 00EA: BSF 20.3
1681 00EB: MOVF 20,W 1681 00EB: MOVF 20,W
1682 00EC: BSF 03.5 1682 00EC: BSF 03.5
1683 00ED: MOVWF 07 1683 00ED: MOVWF 07
1684 00EE: BCF 03.5 1684 00EE: BCF 03.5
1685 00EF: BTFSS 07.3 1685 00EF: BTFSS 07.3
1686 00F0: GOTO 0EF 1686 00F0: GOTO 0EF
1687 00F1: NOP 1687 00F1: NOP
1688 00F2: GOTO 0F3 1688 00F2: GOTO 0F3
1689 00F3: NOP 1689 00F3: NOP
1690 00F4: BSF 20.4 1690 00F4: BSF 20.4
1691 00F5: MOVF 20,W 1691 00F5: MOVF 20,W
1692 00F6: BSF 03.5 1692 00F6: BSF 03.5
1693 00F7: MOVWF 07 1693 00F7: MOVWF 07
1694 00F8: NOP 1694 00F8: NOP
1695 .................... } 1695 .................... }
1696 00F9: BCF 03.5 1696 00F9: BCF 03.5
1697 00FA: RETURN 1697 00FA: RETURN
1698 .................... 1698 ....................
1699 .................... //------------------------------ 1699 .................... //------------------------------
1700 .................... int8 hmc5883l_read_reg(int8 reg) 1700 .................... int8 hmc5883l_read_reg(int8 reg)
1701 .................... { 1701 .................... {
1702 .................... int8 retval; 1702 .................... int8 retval;
1703 .................... 1703 ....................
1704 .................... i2c_start(); 1704 .................... i2c_start();
1705 .................... i2c_write(HMC5883L_WRT_ADDR); 1705 .................... i2c_write(HMC5883L_WRT_ADDR);
1706 .................... i2c_write(reg); 1706 .................... i2c_write(reg);
1707 .................... i2c_start(); 1707 .................... i2c_start();
1708 .................... i2c_write(HMC5883L_READ_ADDR); 1708 .................... i2c_write(HMC5883L_READ_ADDR);
1709 .................... retval = i2c_read(0); 1709 .................... retval = i2c_read(0);
1710 .................... i2c_stop(); 1710 .................... i2c_stop();
1711 .................... 1711 ....................
1712 .................... return(retval); 1712 .................... return(retval);
1713 .................... } 1713 .................... }
1714 .................... 1714 ....................
1715 .................... //------------------------------ 1715 .................... //------------------------------
1716 .................... typedef struct 1716 .................... typedef struct
1717 .................... { 1717 .................... {
1718 .................... signed int16 x; 1718 .................... signed int16 x;
1719 .................... signed int16 y; 1719 .................... signed int16 y;
1720 .................... signed int16 z; 1720 .................... signed int16 z;
1721 .................... }hmc5883l_result; 1721 .................... }hmc5883l_result;
1722 .................... 1722 ....................
1723 .................... // This global structure holds the values read 1723 .................... // This global structure holds the values read
1724 .................... // from the HMC5883L x,y,z registers. 1724 .................... // from the HMC5883L x,y,z registers.
1725 .................... hmc5883l_result compass = {0,0,0}; 1725 .................... hmc5883l_result compass = {0,0,0};
1726 * 1726 *
1727 0ADB: CLRF 21 1727 0D09: CLRF 21
1728 0ADC: CLRF 22 1728 0D0A: CLRF 22
1729 0ADD: CLRF 23 1729 0D0B: CLRF 23
1730 0ADE: CLRF 24 1730 0D0C: CLRF 24
1731 0ADF: CLRF 25 1731 0D0D: CLRF 25
1732 0AE0: CLRF 26 1732 0D0E: CLRF 26
1733 .................... 1733 ....................
1734 .................... //------------------------------ 1734 .................... //------------------------------
1735 .................... void hmc5883l_read_data(void) 1735 .................... void hmc5883l_read_data(void)
1736 .................... { 1736 .................... {
1737 .................... unsigned int8 x_lsb; 1737 .................... unsigned int8 x_lsb;
1738 .................... unsigned int8 x_msb; 1738 .................... unsigned int8 x_msb;
1739 .................... 1739 ....................
1740 .................... unsigned int8 y_lsb; 1740 .................... unsigned int8 y_lsb;
1741 .................... unsigned int8 y_msb; 1741 .................... unsigned int8 y_msb;
1742 .................... 1742 ....................
1743 .................... unsigned int8 z_lsb; 1743 .................... unsigned int8 z_lsb;
1744 .................... unsigned int8 z_msb; 1744 .................... unsigned int8 z_msb;
1745 .................... 1745 ....................
1746 .................... i2c_start(); 1746 .................... i2c_start();
1747 * 1747 *
1748 0800: BSF 20.4 1748 0800: BSF 20.4
1749 0801: MOVF 20,W 1749 0801: MOVF 20,W
1750 0802: BSF 03.5 1750 0802: BSF 03.5
1751 0803: MOVWF 07 1751 0803: MOVWF 07
1752 0804: NOP 1752 0804: NOP
1753 0805: BCF 03.5 1753 0805: BCF 03.5
1754 0806: BSF 20.3 1754 0806: BSF 20.3
1755 0807: MOVF 20,W 1755 0807: MOVF 20,W
1756 0808: BSF 03.5 1756 0808: BSF 03.5
1757 0809: MOVWF 07 1757 0809: MOVWF 07
1758 080A: NOP 1758 080A: NOP
1759 080B: BCF 03.5 1759 080B: BCF 03.5
1760 080C: BCF 07.4 1760 080C: BCF 07.4
1761 080D: BCF 20.4 1761 080D: BCF 20.4
1762 080E: MOVF 20,W 1762 080E: MOVF 20,W
1763 080F: BSF 03.5 1763 080F: BSF 03.5
1764 0810: MOVWF 07 1764 0810: MOVWF 07
1765 0811: NOP 1765 0811: NOP
1766 0812: BCF 03.5 1766 0812: BCF 03.5
1767 0813: BCF 07.3 1767 0813: BCF 07.3
1768 0814: BCF 20.3 1768 0814: BCF 20.3
1769 0815: MOVF 20,W 1769 0815: MOVF 20,W
1770 0816: BSF 03.5 1770 0816: BSF 03.5
1771 0817: MOVWF 07 1771 0817: MOVWF 07
1772 .................... i2c_write(HMC5883L_WRT_ADDR); 1772 .................... i2c_write(HMC5883L_WRT_ADDR);
1773 0818: MOVLW 3C 1773 0818: MOVLW 3C
1774 0819: BCF 03.5 1774 0819: BCF 03.5
1775 081A: MOVWF 3B 1775 081A: MOVWF 4E
1776 081B: BCF 0A.3 1776 081B: BCF 0A.3
1777 081C: CALL 078 1777 081C: CALL 078
1778 081D: BSF 0A.3 1778 081D: BSF 0A.3
1779 .................... i2c_write(HMC5883L_X_MSB_REG); // Point to X-msb register 1779 .................... i2c_write(HMC5883L_X_MSB_REG); // Point to X-msb register
1780 081E: MOVLW 03 1780 081E: MOVLW 03
1781 081F: MOVWF 3B 1781 081F: MOVWF 4E
1782 0820: BCF 0A.3 1782 0820: BCF 0A.3
1783 0821: CALL 078 1783 0821: CALL 078
1784 0822: BSF 0A.3 1784 0822: BSF 0A.3
1785 .................... i2c_start(); 1785 .................... i2c_start();
1786 0823: BSF 20.4 1786 0823: BSF 20.4
1787 0824: MOVF 20,W 1787 0824: MOVF 20,W
1788 0825: BSF 03.5 1788 0825: BSF 03.5
1789 0826: MOVWF 07 1789 0826: MOVWF 07
1790 0827: NOP 1790 0827: NOP
1791 0828: BCF 03.5 1791 0828: BCF 03.5
1792 0829: BSF 20.3 1792 0829: BSF 20.3
1793 082A: MOVF 20,W 1793 082A: MOVF 20,W
1794 082B: BSF 03.5 1794 082B: BSF 03.5
1795 082C: MOVWF 07 1795 082C: MOVWF 07
1796 082D: NOP 1796 082D: NOP
1797 082E: BCF 03.5 1797 082E: BCF 03.5
1798 082F: BTFSS 07.3 1798 082F: BTFSS 07.3
1799 0830: GOTO 02F 1799 0830: GOTO 02F
1800 0831: BCF 07.4 1800 0831: BCF 07.4
1801 0832: BCF 20.4 1801 0832: BCF 20.4
1802 0833: MOVF 20,W 1802 0833: MOVF 20,W
1803 0834: BSF 03.5 1803 0834: BSF 03.5
1804 0835: MOVWF 07 1804 0835: MOVWF 07
1805 0836: NOP 1805 0836: NOP
1806 0837: BCF 03.5 1806 0837: BCF 03.5
1807 0838: BCF 07.3 1807 0838: BCF 07.3
1808 0839: BCF 20.3 1808 0839: BCF 20.3
1809 083A: MOVF 20,W 1809 083A: MOVF 20,W
1810 083B: BSF 03.5 1810 083B: BSF 03.5
1811 083C: MOVWF 07 1811 083C: MOVWF 07
1812 .................... i2c_write(HMC5883L_READ_ADDR); 1812 .................... i2c_write(HMC5883L_READ_ADDR);
1813 083D: MOVLW 3D 1813 083D: MOVLW 3D
1814 083E: BCF 03.5 1814 083E: BCF 03.5
1815 083F: MOVWF 3B 1815 083F: MOVWF 4E
1816 0840: BCF 0A.3 1816 0840: BCF 0A.3
1817 0841: CALL 078 1817 0841: CALL 078
1818 0842: BSF 0A.3 1818 0842: BSF 0A.3
1819 .................... 1819 ....................
1820 .................... x_msb = i2c_read(); 1820 .................... x_msb = i2c_read();
1821 0843: MOVLW 01 1821 0843: MOVLW 01
1822 0844: MOVWF 77 1822 0844: MOVWF 77
1823 0845: BCF 0A.3 1823 0845: BCF 0A.3
1824 0846: CALL 285 1824 0846: CALL 285
1825 0847: BSF 0A.3 1825 0847: BSF 0A.3
1826 0848: MOVF 78,W 1826 0848: MOVF 78,W
1827 0849: MOVWF 36 1827 0849: MOVWF 3E
1828 .................... x_lsb = i2c_read(); 1828 .................... x_lsb = i2c_read();
1829 084A: MOVLW 01 1829 084A: MOVLW 01
1830 084B: MOVWF 77 1830 084B: MOVWF 77
1831 084C: BCF 0A.3 1831 084C: BCF 0A.3
1832 084D: CALL 285 1832 084D: CALL 285
1833 084E: BSF 0A.3 1833 084E: BSF 0A.3
1834 084F: MOVF 78,W 1834 084F: MOVF 78,W
1835 0850: MOVWF 35 1835 0850: MOVWF 3D
1836 .................... 1836 ....................
1837 .................... z_msb = i2c_read(); 1837 .................... z_msb = i2c_read();
1838 0851: MOVLW 01 1838 0851: MOVLW 01
1839 0852: MOVWF 77 1839 0852: MOVWF 77
1840 0853: BCF 0A.3 1840 0853: BCF 0A.3
1841 0854: CALL 285 1841 0854: CALL 285
1842 0855: BSF 0A.3 1842 0855: BSF 0A.3
1843 0856: MOVF 78,W 1843 0856: MOVF 78,W
1844 0857: MOVWF 3A 1844 0857: MOVWF 42
1845 .................... z_lsb = i2c_read(); 1845 .................... z_lsb = i2c_read();
1846 0858: MOVLW 01 1846 0858: MOVLW 01
1847 0859: MOVWF 77 1847 0859: MOVWF 77
1848 085A: BCF 0A.3 1848 085A: BCF 0A.3
1849 085B: CALL 285 1849 085B: CALL 285
1850 085C: BSF 0A.3 1850 085C: BSF 0A.3
1851 085D: MOVF 78,W 1851 085D: MOVF 78,W
1852 085E: MOVWF 39 1852 085E: MOVWF 41
1853 .................... 1853 ....................
1854 .................... y_msb = i2c_read(); 1854 .................... y_msb = i2c_read();
1855 085F: MOVLW 01 1855 085F: MOVLW 01
1856 0860: MOVWF 77 1856 0860: MOVWF 77
1857 0861: BCF 0A.3 1857 0861: BCF 0A.3
1858 0862: CALL 285 1858 0862: CALL 285
1859 0863: BSF 0A.3 1859 0863: BSF 0A.3
1860 0864: MOVF 78,W 1860 0864: MOVF 78,W
1861 0865: MOVWF 38 1861 0865: MOVWF 40
1862 .................... y_lsb = i2c_read(0); // do a NACK on last read 1862 .................... y_lsb = i2c_read(0); // do a NACK on last read
1863 0866: CLRF 77 1863 0866: CLRF 77
1864 0867: BCF 0A.3 1864 0867: BCF 0A.3
1865 0868: CALL 285 1865 0868: CALL 285
1866 0869: BSF 0A.3 1866 0869: BSF 0A.3
1867 086A: MOVF 78,W 1867 086A: MOVF 78,W
1868 086B: MOVWF 37 1868 086B: MOVWF 3F
1869 .................... 1869 ....................
1870 .................... i2c_stop(); 1870 .................... i2c_stop();
1871 086C: BCF 20.4 1871 086C: BCF 20.4
1872 086D: MOVF 20,W 1872 086D: MOVF 20,W
1873 086E: BSF 03.5 1873 086E: BSF 03.5
1874 086F: MOVWF 07 1874 086F: MOVWF 07
1875 0870: NOP 1875 0870: NOP
1876 0871: BCF 03.5 1876 0871: BCF 03.5
1877 0872: BSF 20.3 1877 0872: BSF 20.3
1878 0873: MOVF 20,W 1878 0873: MOVF 20,W
1879 0874: BSF 03.5 1879 0874: BSF 03.5
1880 0875: MOVWF 07 1880 0875: MOVWF 07
1881 0876: BCF 03.5 1881 0876: BCF 03.5
1882 0877: BTFSS 07.3 1882 0877: BTFSS 07.3
1883 0878: GOTO 077 1883 0878: GOTO 077
1884 0879: NOP 1884 0879: NOP
1885 087A: GOTO 07B 1885 087A: GOTO 07B
1886 087B: NOP 1886 087B: NOP
1887 087C: BSF 20.4 1887 087C: BSF 20.4
1888 087D: MOVF 20,W 1888 087D: MOVF 20,W
1889 087E: BSF 03.5 1889 087E: BSF 03.5
1890 087F: MOVWF 07 1890 087F: MOVWF 07
1891 0880: NOP 1891 0880: NOP
1892 .................... 1892 ....................
1893 .................... // Combine high and low bytes into 16-bit values. 1893 .................... // Combine high and low bytes into 16-bit values.
1894 .................... compass.x = make16(x_msb, x_lsb); 1894 .................... compass.x = make16(x_msb, x_lsb);
1895 0881: BCF 03.5 1895 0881: BCF 03.5
1896 0882: MOVF 36,W 1896 0882: MOVF 3E,W
1897 0883: MOVWF 22 1897 0883: MOVWF 22
1898 0884: MOVF 35,W 1898 0884: MOVF 3D,W
1899 0885: MOVWF 21 1899 0885: MOVWF 21
1900 .................... compass.y = make16(y_msb, y_lsb); 1900 .................... compass.y = make16(y_msb, y_lsb);
1901 0886: MOVF 38,W 1901 0886: MOVF 40,W
1902 0887: MOVWF 24 1902 0887: MOVWF 24
1903 0888: MOVF 37,W 1903 0888: MOVF 3F,W
1904 0889: MOVWF 23 1904 0889: MOVWF 23
1905 .................... compass.z = make16(z_msb, z_lsb); 1905 .................... compass.z = make16(z_msb, z_lsb);
1906 088A: MOVF 3A,W 1906 088A: MOVF 42,W
1907 088B: MOVWF 26 1907 088B: MOVWF 26
1908 088C: MOVF 39,W 1908 088C: MOVF 41,W
1909 088D: MOVWF 25 1909 088D: MOVWF 25
1910 .................... } 1910 .................... }
1911 088E: BSF 0A.3 1911 088E: BSF 0A.3
1912 088F: BCF 0A.4 1912 088F: BCF 0A.4
1913 0890: GOTO 3AB (RETURN) 1913 0890: GOTO 5D9 (RETURN)
1914 .................... 1914 ....................
1915 .................... 1915 ....................
1916 .................... 1916 ....................
1917 .................... 1917 ....................
1918 .................... #include <math.h> 1918 .................... #include <math.h>
1919 .................... //////////////////////////////////////////////////////////////////////////// 1919 .................... ////////////////////////////////////////////////////////////////////////////
1920 .................... //// (C) Copyright 1996,2008 Custom Computer Services //// 1920 .................... //// (C) Copyright 1996,2008 Custom Computer Services ////
1921 .................... //// This source code may only be used by licensed users of the CCS C //// 1921 .................... //// This source code may only be used by licensed users of the CCS C ////
1922 .................... //// compiler. This source code may only be distributed to other //// 1922 .................... //// compiler. This source code may only be distributed to other ////
1923 .................... //// licensed users of the CCS C compiler. No other use, reproduction //// 1923 .................... //// licensed users of the CCS C compiler. No other use, reproduction ////
1924 .................... //// or distribution is permitted without written permission. //// 1924 .................... //// or distribution is permitted without written permission. ////
1925 .................... //// Derivative programs created using this software in object code //// 1925 .................... //// Derivative programs created using this software in object code ////
1926 .................... //// form are not restricted in any way. //// 1926 .................... //// form are not restricted in any way. ////
1927 .................... //////////////////////////////////////////////////////////////////////////// 1927 .................... ////////////////////////////////////////////////////////////////////////////
1928 .................... //// //// 1928 .................... //// ////
1929 .................... //// History: //// 1929 .................... //// History: ////
1930 .................... //// * 9/20/2001 : Improvments are made to sin/cos code. //// 1930 .................... //// * 9/20/2001 : Improvments are made to sin/cos code. ////
1931 .................... //// The code now is small, much faster, //// 1931 .................... //// The code now is small, much faster, ////
1932 .................... //// and more accurate. //// 1932 .................... //// and more accurate. ////
1933 .................... //// * 2/21/2007 : Compiler handles & operator differently and does 1933 .................... //// * 2/21/2007 : Compiler handles & operator differently and does
1934 .................... //// not return generic (int8 *) so type cast is done //// 1934 .................... //// not return generic (int8 *) so type cast is done ////
1935 .................... //// //// 1935 .................... //// ////
1936 .................... //////////////////////////////////////////////////////////////////////////// 1936 .................... ////////////////////////////////////////////////////////////////////////////
1937 .................... 1937 ....................
1938 .................... #ifndef MATH_H 1938 .................... #ifndef MATH_H
1939 .................... #define MATH_H 1939 .................... #define MATH_H
1940 .................... 1940 ....................
1941 .................... #ifdef PI 1941 .................... #ifdef PI
1942 .................... #undef PI 1942 .................... #undef PI
1943 .................... #endif 1943 .................... #endif
1944 .................... #define PI 3.1415926535897932 1944 .................... #define PI 3.1415926535897932
1945 .................... 1945 ....................
1946 .................... 1946 ....................
1947 .................... #define SQRT2 1.4142135623730950 1947 .................... #define SQRT2 1.4142135623730950
1948 .................... 1948 ....................
1949 .................... //float const ps[4] = {5.9304945, 21.125224, 8.9403076, 0.29730279}; 1949 .................... //float const ps[4] = {5.9304945, 21.125224, 8.9403076, 0.29730279};
1950 .................... //float const qs[4] = {1.0000000, 15.035723, 17.764134, 2.4934718}; 1950 .................... //float const qs[4] = {1.0000000, 15.035723, 17.764134, 2.4934718};
1951 .................... 1951 ....................
1952 .................... ///////////////////////////// Round Functions ////////////////////////////// 1952 .................... ///////////////////////////// Round Functions //////////////////////////////
1953 .................... 1953 ....................
1954 .................... float32 CEIL_FLOOR(float32 x, unsigned int8 n) 1954 .................... float32 CEIL_FLOOR(float32 x, unsigned int8 n)
1955 .................... { 1955 .................... {
1956 .................... float32 y, res; 1956 .................... float32 y, res;
1957 .................... unsigned int16 l; 1957 .................... unsigned int16 l;
1958 .................... int1 s; 1958 .................... int1 s;
1959 .................... 1959 ....................
1960 .................... s = 0; 1960 .................... s = 0;
1961 .................... y = x; 1961 .................... y = x;
1962 .................... 1962 ....................
1963 .................... if (x < 0) 1963 .................... if (x < 0)
1964 .................... { 1964 .................... {
1965 .................... s = 1; 1965 .................... s = 1;
1966 .................... y = -y; 1966 .................... y = -y;
1967 .................... } 1967 .................... }
1968 .................... 1968 ....................
1969 .................... if (y <= 32768.0) 1969 .................... if (y <= 32768.0)
1970 .................... res = (float32)(unsigned int16)y; 1970 .................... res = (float32)(unsigned int16)y;
1971 .................... 1971 ....................
1972 .................... else if (y < 10000000.0) 1972 .................... else if (y < 10000000.0)
1973 .................... { 1973 .................... {
1974 .................... l = (unsigned int16)(y/32768.0); 1974 .................... l = (unsigned int16)(y/32768.0);
1975 .................... y = 32768.0*(y/32768.0 - (float32)l); 1975 .................... y = 32768.0*(y/32768.0 - (float32)l);
1976 .................... res = 32768.0*(float32)l; 1976 .................... res = 32768.0*(float32)l;
1977 .................... res += (float32)(unsigned int16)y; 1977 .................... res += (float32)(unsigned int16)y;
1978 .................... } 1978 .................... }
1979 .................... 1979 ....................
1980 .................... else 1980 .................... else
1981 .................... res = y; 1981 .................... res = y;
1982 .................... 1982 ....................
1983 .................... y = y - (float32)(unsigned int16)y; 1983 .................... y = y - (float32)(unsigned int16)y;
1984 .................... 1984 ....................
1985 .................... if (s) 1985 .................... if (s)
1986 .................... res = -res; 1986 .................... res = -res;
1987 .................... 1987 ....................
1988 .................... if (y != 0) 1988 .................... if (y != 0)
1989 .................... { 1989 .................... {
1990 .................... if (s == 1 && n == 0) 1990 .................... if (s == 1 && n == 0)
1991 .................... res -= 1.0; 1991 .................... res -= 1.0;
1992 .................... 1992 ....................
1993 .................... if (s == 0 && n == 1) 1993 .................... if (s == 0 && n == 1)
1994 .................... res += 1.0; 1994 .................... res += 1.0;
1995 .................... } 1995 .................... }
1996 .................... if (x == 0) 1996 .................... if (x == 0)
1997 .................... res = 0; 1997 .................... res = 0;
1998 .................... 1998 ....................
1999 .................... return (res); 1999 .................... return (res);
2000 .................... } 2000 .................... }
2001 .................... 2001 ....................
2002 .................... // Overloaded Functions to take care for new Data types in PCD 2002 .................... // Overloaded Functions to take care for new Data types in PCD
2003 .................... // Overloaded function CEIL_FLOOR() for data type - Float48 2003 .................... // Overloaded function CEIL_FLOOR() for data type - Float48
2004 .................... #if defined(__PCD__) 2004 .................... #if defined(__PCD__)
2005 .................... float48 CEIL_FLOOR(float48 x, unsigned int8 n) 2005 .................... float48 CEIL_FLOOR(float48 x, unsigned int8 n)
2006 .................... { 2006 .................... {
2007 .................... float48 y, res; 2007 .................... float48 y, res;
2008 .................... unsigned int16 l; 2008 .................... unsigned int16 l;
2009 .................... int1 s; 2009 .................... int1 s;
2010 .................... 2010 ....................
2011 .................... s = 0; 2011 .................... s = 0;
2012 .................... y = x; 2012 .................... y = x;
2013 .................... 2013 ....................
2014 .................... if (x < 0) 2014 .................... if (x < 0)
2015 .................... { 2015 .................... {
2016 .................... s = 1; 2016 .................... s = 1;
2017 .................... y = -y; 2017 .................... y = -y;
2018 .................... } 2018 .................... }
2019 .................... 2019 ....................
2020 .................... if (y <= 32768.0) 2020 .................... if (y <= 32768.0)
2021 .................... res = (float48)(unsigned int16)y; 2021 .................... res = (float48)(unsigned int16)y;
2022 .................... 2022 ....................
2023 .................... else if (y < 10000000.0) 2023 .................... else if (y < 10000000.0)
2024 .................... { 2024 .................... {
2025 .................... l = (unsigned int16)(y/32768.0); 2025 .................... l = (unsigned int16)(y/32768.0);
2026 .................... y = 32768.0*(y/32768.0 - (float48)l); 2026 .................... y = 32768.0*(y/32768.0 - (float48)l);
2027 .................... res = 32768.0*(float32)l; 2027 .................... res = 32768.0*(float32)l;
2028 .................... res += (float48)(unsigned int16)y; 2028 .................... res += (float48)(unsigned int16)y;
2029 .................... } 2029 .................... }
2030 .................... 2030 ....................
2031 .................... else 2031 .................... else
2032 .................... res = y; 2032 .................... res = y;
2033 .................... 2033 ....................
2034 .................... y = y - (float48)(unsigned int16)y; 2034 .................... y = y - (float48)(unsigned int16)y;
2035 .................... 2035 ....................
2036 .................... if (s) 2036 .................... if (s)
2037 .................... res = -res; 2037 .................... res = -res;
2038 .................... 2038 ....................
2039 .................... if (y != 0) 2039 .................... if (y != 0)
2040 .................... { 2040 .................... {
2041 .................... if (s == 1 && n == 0) 2041 .................... if (s == 1 && n == 0)
2042 .................... res -= 1.0; 2042 .................... res -= 1.0;
2043 .................... 2043 ....................
2044 .................... if (s == 0 && n == 1) 2044 .................... if (s == 0 && n == 1)
2045 .................... res += 1.0; 2045 .................... res += 1.0;
2046 .................... } 2046 .................... }
2047 .................... if (x == 0) 2047 .................... if (x == 0)
2048 .................... res = 0; 2048 .................... res = 0;
2049 .................... 2049 ....................
2050 .................... return (res); 2050 .................... return (res);
2051 .................... } 2051 .................... }
2052 .................... 2052 ....................
2053 .................... 2053 ....................
2054 .................... // Overloaded function CEIL_FLOOR() for data type - Float64 2054 .................... // Overloaded function CEIL_FLOOR() for data type - Float64
2055 .................... float64 CEIL_FLOOR(float64 x, unsigned int8 n) 2055 .................... float64 CEIL_FLOOR(float64 x, unsigned int8 n)
2056 .................... { 2056 .................... {
2057 .................... float64 y, res; 2057 .................... float64 y, res;
2058 .................... unsigned int16 l; 2058 .................... unsigned int16 l;
2059 .................... int1 s; 2059 .................... int1 s;
2060 .................... 2060 ....................
2061 .................... s = 0; 2061 .................... s = 0;
2062 .................... y = x; 2062 .................... y = x;
2063 .................... 2063 ....................
2064 .................... if (x < 0) 2064 .................... if (x < 0)
2065 .................... { 2065 .................... {
2066 .................... s = 1; 2066 .................... s = 1;
2067 .................... y = -y; 2067 .................... y = -y;
2068 .................... } 2068 .................... }
2069 .................... 2069 ....................
2070 .................... if (y <= 32768.0) 2070 .................... if (y <= 32768.0)
2071 .................... res = (float64)(unsigned int16)y; 2071 .................... res = (float64)(unsigned int16)y;
2072 .................... 2072 ....................
2073 .................... else if (y < 10000000.0) 2073 .................... else if (y < 10000000.0)
2074 .................... { 2074 .................... {
2075 .................... l = (unsigned int16)(y/32768.0); 2075 .................... l = (unsigned int16)(y/32768.0);
2076 .................... y = 32768.0*(y/32768.0 - (float64)l); 2076 .................... y = 32768.0*(y/32768.0 - (float64)l);
2077 .................... res = 32768.0*(float64)l; 2077 .................... res = 32768.0*(float64)l;
2078 .................... res += (float64)(unsigned int16)y; 2078 .................... res += (float64)(unsigned int16)y;
2079 .................... } 2079 .................... }
2080 .................... 2080 ....................
2081 .................... else 2081 .................... else
2082 .................... res = y; 2082 .................... res = y;
2083 .................... 2083 ....................
2084 .................... y = y - (float64)(unsigned int16)y; 2084 .................... y = y - (float64)(unsigned int16)y;
2085 .................... 2085 ....................
2086 .................... if (s) 2086 .................... if (s)
2087 .................... res = -res; 2087 .................... res = -res;
2088 .................... 2088 ....................
2089 .................... if (y != 0) 2089 .................... if (y != 0)
2090 .................... { 2090 .................... {
2091 .................... if (s == 1 && n == 0) 2091 .................... if (s == 1 && n == 0)
2092 .................... res -= 1.0; 2092 .................... res -= 1.0;
2093 .................... 2093 ....................
2094 .................... if (s == 0 && n == 1) 2094 .................... if (s == 0 && n == 1)
2095 .................... res += 1.0; 2095 .................... res += 1.0;
2096 .................... } 2096 .................... }
2097 .................... if (x == 0) 2097 .................... if (x == 0)
2098 .................... res = 0; 2098 .................... res = 0;
2099 .................... 2099 ....................
2100 .................... return (res); 2100 .................... return (res);
2101 .................... } 2101 .................... }
2102 .................... #endif 2102 .................... #endif
2103 .................... 2103 ....................
2104 .................... //////////////////////////////////////////////////////////////////////////// 2104 .................... ////////////////////////////////////////////////////////////////////////////
2105 .................... // float floor(float x) 2105 .................... // float floor(float x)
2106 .................... //////////////////////////////////////////////////////////////////////////// 2106 .................... ////////////////////////////////////////////////////////////////////////////
2107 .................... // Description : rounds down the number x. 2107 .................... // Description : rounds down the number x.
2108 .................... // Date : N/A 2108 .................... // Date : N/A
2109 .................... // 2109 .................... //
2110 .................... float32 floor(float32 x) 2110 .................... float32 floor(float32 x)
2111 .................... { 2111 .................... {
2112 .................... return CEIL_FLOOR(x, 0); 2112 .................... return CEIL_FLOOR(x, 0);
2113 .................... } 2113 .................... }
2114 .................... // Following 2 functions are overloaded functions of floor() for PCD 2114 .................... // Following 2 functions are overloaded functions of floor() for PCD
2115 .................... // Overloaded function floor() for data type - Float48 2115 .................... // Overloaded function floor() for data type - Float48
2116 .................... #if defined(__PCD__) 2116 .................... #if defined(__PCD__)
2117 .................... float48 floor(float48 x) 2117 .................... float48 floor(float48 x)
2118 .................... { 2118 .................... {
2119 .................... return CEIL_FLOOR(x, 0); 2119 .................... return CEIL_FLOOR(x, 0);
2120 .................... } 2120 .................... }
2121 .................... 2121 ....................
2122 .................... // Overloaded function floor() for data type - Float64 2122 .................... // Overloaded function floor() for data type - Float64
2123 .................... float64 floor(float64 x) 2123 .................... float64 floor(float64 x)
2124 .................... { 2124 .................... {
2125 .................... return CEIL_FLOOR(x, 0); 2125 .................... return CEIL_FLOOR(x, 0);
2126 .................... } 2126 .................... }
2127 .................... #endif 2127 .................... #endif
2128 .................... 2128 ....................
2129 .................... 2129 ....................
2130 .................... //////////////////////////////////////////////////////////////////////////// 2130 .................... ////////////////////////////////////////////////////////////////////////////
2131 .................... // float ceil(float x) 2131 .................... // float ceil(float x)
2132 .................... //////////////////////////////////////////////////////////////////////////// 2132 .................... ////////////////////////////////////////////////////////////////////////////
2133 .................... // Description : rounds up the number x. 2133 .................... // Description : rounds up the number x.
2134 .................... // Date : N/A 2134 .................... // Date : N/A
2135 .................... // 2135 .................... //
2136 .................... float32 ceil(float32 x) 2136 .................... float32 ceil(float32 x)
2137 .................... { 2137 .................... {
2138 .................... return CEIL_FLOOR(x, 1); 2138 .................... return CEIL_FLOOR(x, 1);
2139 .................... } 2139 .................... }
2140 .................... // Following 2 functions are overloaded functions of ceil() for PCD 2140 .................... // Following 2 functions are overloaded functions of ceil() for PCD
2141 .................... // Overloaded function ceil() for data type - Float48 2141 .................... // Overloaded function ceil() for data type - Float48
2142 .................... #if defined(__PCD__) 2142 .................... #if defined(__PCD__)
2143 .................... float48 ceil(float48 x) 2143 .................... float48 ceil(float48 x)
2144 .................... { 2144 .................... {
2145 .................... return CEIL_FLOOR(x, 1); 2145 .................... return CEIL_FLOOR(x, 1);
2146 .................... } 2146 .................... }
2147 .................... 2147 ....................
2148 .................... // Overloaded function ceil() for data type - Float64 2148 .................... // Overloaded function ceil() for data type - Float64
2149 .................... float64 ceil(float64 x) 2149 .................... float64 ceil(float64 x)
2150 .................... { 2150 .................... {
2151 .................... return CEIL_FLOOR(x, 1); 2151 .................... return CEIL_FLOOR(x, 1);
2152 .................... } 2152 .................... }
2153 .................... #endif 2153 .................... #endif
2154 .................... 2154 ....................
2155 .................... //////////////////////////////////////////////////////////////////////////// 2155 .................... ////////////////////////////////////////////////////////////////////////////
2156 .................... // float fabs(float x) 2156 .................... // float fabs(float x)
2157 .................... //////////////////////////////////////////////////////////////////////////// 2157 .................... ////////////////////////////////////////////////////////////////////////////
2158 .................... // Description : Computes the absolute value of floating point number x 2158 .................... // Description : Computes the absolute value of floating point number x
2159 .................... // Returns : returns the absolute value of x 2159 .................... // Returns : returns the absolute value of x
2160 .................... // Date : N/A 2160 .................... // Date : N/A
2161 .................... // 2161 .................... //
2162 .................... #define fabs abs 2162 .................... #define fabs abs
2163 .................... 2163 ....................
2164 .................... //////////////////////////////////////////////////////////////////////////// 2164 .................... ////////////////////////////////////////////////////////////////////////////
2165 .................... // float fmod(float x) 2165 .................... // float fmod(float x)
2166 .................... //////////////////////////////////////////////////////////////////////////// 2166 .................... ////////////////////////////////////////////////////////////////////////////
2167 .................... // Description : Computes the floating point remainder of x/y 2167 .................... // Description : Computes the floating point remainder of x/y
2168 .................... // Returns : returns the value of x= i*y, for some integer i such that, if y 2168 .................... // Returns : returns the value of x= i*y, for some integer i such that, if y
2169 .................... // is non zero, the result has the same isgn of x na dmagnitude less than the 2169 .................... // is non zero, the result has the same isgn of x na dmagnitude less than the
2170 .................... // magnitude of y. If y is zero then a domain error occurs. 2170 .................... // magnitude of y. If y is zero then a domain error occurs.
2171 .................... // Date : N/A 2171 .................... // Date : N/A
2172 .................... // 2172 .................... //
2173 .................... 2173 ....................
2174 .................... float fmod(float32 x,float32 y) 2174 .................... float fmod(float32 x,float32 y)
2175 .................... { 2175 .................... {
2176 .................... float32 i; 2176 .................... float32 i;
2177 .................... if (y!=0.0) 2177 .................... if (y!=0.0)
2178 .................... { 2178 .................... {
2179 .................... i=(x/y < 0.0)? ceil(x/y): floor(x/y); 2179 .................... i=(x/y < 0.0)? ceil(x/y): floor(x/y);
2180 .................... return(x-(i*y)); 2180 .................... return(x-(i*y));
2181 .................... } 2181 .................... }
2182 .................... else 2182 .................... else
2183 .................... { 2183 .................... {
2184 .................... #ifdef _ERRNO 2184 .................... #ifdef _ERRNO
2185 .................... { 2185 .................... {
2186 .................... errno=EDOM; 2186 .................... errno=EDOM;
2187 .................... } 2187 .................... }
2188 .................... #endif 2188 .................... #endif
2189 .................... } 2189 .................... }
2190 .................... } 2190 .................... }
2191 .................... //Overloaded function for fmod() for PCD 2191 .................... //Overloaded function for fmod() for PCD
2192 .................... // Overloaded function fmod() for data type - Float48 2192 .................... // Overloaded function fmod() for data type - Float48
2193 .................... #if defined(__PCD__) 2193 .................... #if defined(__PCD__)
2194 .................... float48 fmod(float48 x,float48 y) 2194 .................... float48 fmod(float48 x,float48 y)
2195 .................... { 2195 .................... {
2196 .................... float48 i; 2196 .................... float48 i;
2197 .................... if (y!=0.0) 2197 .................... if (y!=0.0)
2198 .................... { 2198 .................... {
2199 .................... i=(x/y < 0.0)? ceil(x/y): floor(x/y); 2199 .................... i=(x/y < 0.0)? ceil(x/y): floor(x/y);
2200 .................... return(x-(i*y)); 2200 .................... return(x-(i*y));
2201 .................... } 2201 .................... }
2202 .................... else 2202 .................... else
2203 .................... { 2203 .................... {
2204 .................... #ifdef _ERRNO 2204 .................... #ifdef _ERRNO
2205 .................... { 2205 .................... {
2206 .................... errno=EDOM; 2206 .................... errno=EDOM;
2207 .................... } 2207 .................... }
2208 .................... #endif 2208 .................... #endif
2209 .................... } 2209 .................... }
2210 .................... } 2210 .................... }
2211 .................... // Overloaded function fmod() for data type - Float64 2211 .................... // Overloaded function fmod() for data type - Float64
2212 .................... float64 fmod(float64 x,float64 y) 2212 .................... float64 fmod(float64 x,float64 y)
2213 .................... { 2213 .................... {
2214 .................... float64 i; 2214 .................... float64 i;
2215 .................... if (y!=0.0) 2215 .................... if (y!=0.0)
2216 .................... { 2216 .................... {
2217 .................... i=(x/y < 0.0)? ceil(x/y): floor(x/y); 2217 .................... i=(x/y < 0.0)? ceil(x/y): floor(x/y);
2218 .................... return(x-(i*y)); 2218 .................... return(x-(i*y));
2219 .................... } 2219 .................... }
2220 .................... else 2220 .................... else
2221 .................... { 2221 .................... {
2222 .................... #ifdef _ERRNO 2222 .................... #ifdef _ERRNO
2223 .................... { 2223 .................... {
2224 .................... errno=EDOM; 2224 .................... errno=EDOM;
2225 .................... } 2225 .................... }
2226 .................... #endif 2226 .................... #endif
2227 .................... } 2227 .................... }
2228 .................... } 2228 .................... }
2229 .................... #endif 2229 .................... #endif
2230 .................... //////////////////// Exponential and logarithmic functions //////////////////// 2230 .................... //////////////////// Exponential and logarithmic functions ////////////////////
2231 .................... //////////////////////////////////////////////////////////////////////////// 2231 .................... ////////////////////////////////////////////////////////////////////////////
2232 .................... // float exp(float x) 2232 .................... // float exp(float x)
2233 .................... //////////////////////////////////////////////////////////////////////////// 2233 .................... ////////////////////////////////////////////////////////////////////////////
2234 .................... // Description : returns the value (e^x) 2234 .................... // Description : returns the value (e^x)
2235 .................... // Date : N/A 2235 .................... // Date : N/A
2236 .................... // 2236 .................... //
2237 .................... #define LN2 0.6931471805599453 2237 .................... #define LN2 0.6931471805599453
2238 .................... 2238 ....................
2239 .................... float const pe[6] = {0.000207455774, 0.00127100575, 0.00965065093, 2239 .................... float const pe[6] = {0.000207455774, 0.00127100575, 0.00965065093,
2240 .................... 0.0554965651, 0.240227138, 0.693147172}; 2240 .................... 0.0554965651, 0.240227138, 0.693147172};
2241 .................... 2241 ....................
2242 .................... 2242 ....................
2243 .................... float32 exp(float32 x) 2243 .................... float32 exp(float32 x)
2244 .................... { 2244 .................... {
2245 .................... float32 y, res, r; 2245 .................... float32 y, res, r;
2246 .................... #if defined(__PCD__) 2246 .................... #if defined(__PCD__)
2247 .................... int8 data1; 2247 .................... int8 data1;
2248 .................... #endif 2248 .................... #endif
2249 .................... signed int8 n; 2249 .................... signed int8 n;
2250 .................... int1 s; 2250 .................... int1 s;
2251 .................... #ifdef _ERRNO 2251 .................... #ifdef _ERRNO
2252 .................... if(x > 88.722838) 2252 .................... if(x > 88.722838)
2253 .................... { 2253 .................... {
2254 .................... errno=ERANGE; 2254 .................... errno=ERANGE;
2255 .................... return(0); 2255 .................... return(0);
2256 .................... } 2256 .................... }
2257 .................... #endif 2257 .................... #endif
2258 .................... n = (signed int16)(x/LN2); 2258 .................... n = (signed int16)(x/LN2);
2259 .................... s = 0; 2259 .................... s = 0;
2260 .................... y = x; 2260 .................... y = x;
2261 .................... 2261 ....................
2262 .................... if (x < 0) 2262 .................... if (x < 0)
2263 .................... { 2263 .................... {
2264 .................... s = 1; 2264 .................... s = 1;
2265 .................... n = -n; 2265 .................... n = -n;
2266 .................... y = -y; 2266 .................... y = -y;
2267 .................... } 2267 .................... }
2268 .................... 2268 ....................
2269 .................... res = 0.0; 2269 .................... res = 0.0;
2270 .................... #if !defined(__PCD__) 2270 .................... #if !defined(__PCD__)
2271 .................... *((unsigned int8 *)(&res)) = n + 0x7F; 2271 .................... *((unsigned int8 *)(&res)) = n + 0x7F;
2272 .................... #endif 2272 .................... #endif
2273 .................... 2273 ....................
2274 .................... #if defined(__PCD__) // Takes care of IEEE format for PCD 2274 .................... #if defined(__PCD__) // Takes care of IEEE format for PCD
2275 .................... data1 = n+0x7F; 2275 .................... data1 = n+0x7F;
2276 .................... if(bit_test(data1,0)) 2276 .................... if(bit_test(data1,0))
2277 .................... bit_set(*(((unsigned int8 *)(&res)+2)),7); 2277 .................... bit_set(*(((unsigned int8 *)(&res)+2)),7);
2278 .................... rotate_right(&data1,1); 2278 .................... rotate_right(&data1,1);
2279 .................... bit_clear(data1,7); 2279 .................... bit_clear(data1,7);
2280 .................... *(((unsigned int8 *)(&res)+3)) = data1; 2280 .................... *(((unsigned int8 *)(&res)+3)) = data1;
2281 .................... #endif 2281 .................... #endif
2282 .................... 2282 ....................
2283 .................... y = y/LN2 - (float32)n; 2283 .................... y = y/LN2 - (float32)n;
2284 .................... 2284 ....................
2285 .................... r = pe[0]*y + pe[1]; 2285 .................... r = pe[0]*y + pe[1];
2286 .................... r = r*y + pe[2]; 2286 .................... r = r*y + pe[2];
2287 .................... r = r*y + pe[3]; 2287 .................... r = r*y + pe[3];
2288 .................... r = r*y + pe[4]; 2288 .................... r = r*y + pe[4];
2289 .................... r = r*y + pe[5]; 2289 .................... r = r*y + pe[5];
2290 .................... 2290 ....................
2291 .................... res = res*(1.0 + y*r); 2291 .................... res = res*(1.0 + y*r);
2292 .................... 2292 ....................
2293 .................... if (s) 2293 .................... if (s)
2294 .................... res = 1.0/res; 2294 .................... res = 1.0/res;
2295 .................... return(res); 2295 .................... return(res);
2296 .................... } 2296 .................... }
2297 .................... 2297 ....................
2298 .................... 2298 ....................
2299 .................... //Overloaded function for exp() for PCD 2299 .................... //Overloaded function for exp() for PCD
2300 .................... // Overloaded function exp() for data type - Float48 2300 .................... // Overloaded function exp() for data type - Float48
2301 .................... #if defined(__PCD__) 2301 .................... #if defined(__PCD__)
2302 .................... float48 exp(float48 x) 2302 .................... float48 exp(float48 x)
2303 .................... { 2303 .................... {
2304 .................... float48 y, res, r; 2304 .................... float48 y, res, r;
2305 .................... int8 data1; 2305 .................... int8 data1;
2306 .................... signed int8 n; 2306 .................... signed int8 n;
2307 .................... int1 s; 2307 .................... int1 s;
2308 .................... #ifdef _ERRNO 2308 .................... #ifdef _ERRNO
2309 .................... if(x > 88.722838) 2309 .................... if(x > 88.722838)
2310 .................... { 2310 .................... {
2311 .................... errno=ERANGE; 2311 .................... errno=ERANGE;
2312 .................... return(0); 2312 .................... return(0);
2313 .................... } 2313 .................... }
2314 .................... #endif 2314 .................... #endif
2315 .................... n = (signed int16)(x/LN2); 2315 .................... n = (signed int16)(x/LN2);
2316 .................... s = 0; 2316 .................... s = 0;
2317 .................... y = x; 2317 .................... y = x;
2318 .................... 2318 ....................
2319 .................... if (x < 0) 2319 .................... if (x < 0)
2320 .................... { 2320 .................... {
2321 .................... s = 1; 2321 .................... s = 1;
2322 .................... n = -n; 2322 .................... n = -n;
2323 .................... y = -y; 2323 .................... y = -y;
2324 .................... } 2324 .................... }
2325 .................... 2325 ....................
2326 .................... res = 0.0; 2326 .................... res = 0.0;
2327 .................... 2327 ....................
2328 .................... data1 = n+0x7F; 2328 .................... data1 = n+0x7F;
2329 .................... if(bit_test(data1,0)) 2329 .................... if(bit_test(data1,0))
2330 .................... bit_set(*(((unsigned int8 *)(&res)+4)),7); 2330 .................... bit_set(*(((unsigned int8 *)(&res)+4)),7);
2331 .................... rotate_right(&data1,1); 2331 .................... rotate_right(&data1,1);
2332 .................... bit_clear(data1,7); 2332 .................... bit_clear(data1,7);
2333 .................... *(((unsigned int8 *)(&res)+5)) = data1; 2333 .................... *(((unsigned int8 *)(&res)+5)) = data1;
2334 .................... 2334 ....................
2335 .................... y = y/LN2 - (float48)n; 2335 .................... y = y/LN2 - (float48)n;
2336 .................... 2336 ....................
2337 .................... r = pe[0]*y + pe[1]; 2337 .................... r = pe[0]*y + pe[1];
2338 .................... r = r*y + pe[2]; 2338 .................... r = r*y + pe[2];
2339 .................... r = r*y + pe[3]; 2339 .................... r = r*y + pe[3];
2340 .................... r = r*y + pe[4]; 2340 .................... r = r*y + pe[4];
2341 .................... r = r*y + pe[5]; 2341 .................... r = r*y + pe[5];
2342 .................... 2342 ....................
2343 .................... res = res*(1.0 + y*r); 2343 .................... res = res*(1.0 + y*r);
2344 .................... 2344 ....................
2345 .................... if (s) 2345 .................... if (s)
2346 .................... res = 1.0/res; 2346 .................... res = 1.0/res;
2347 .................... return(res); 2347 .................... return(res);
2348 .................... } 2348 .................... }
2349 .................... 2349 ....................
2350 .................... // Overloaded function exp() for data type - Float64 2350 .................... // Overloaded function exp() for data type - Float64
2351 .................... float64 exp(float64 x) 2351 .................... float64 exp(float64 x)
2352 .................... { 2352 .................... {
2353 .................... float64 y, res, r; 2353 .................... float64 y, res, r;
2354 .................... unsigned int16 data1, data2; 2354 .................... unsigned int16 data1, data2;
2355 .................... unsigned int16 *p; 2355 .................... unsigned int16 *p;
2356 .................... signed int16 n; 2356 .................... signed int16 n;
2357 .................... int1 s; 2357 .................... int1 s;
2358 .................... #ifdef _ERRNO 2358 .................... #ifdef _ERRNO
2359 .................... if(x > 709.7827128) 2359 .................... if(x > 709.7827128)
2360 .................... { 2360 .................... {
2361 .................... errno=ERANGE; 2361 .................... errno=ERANGE;
2362 .................... return(0); 2362 .................... return(0);
2363 .................... } 2363 .................... }
2364 .................... #endif 2364 .................... #endif
2365 .................... n = (signed int16)(x/LN2); 2365 .................... n = (signed int16)(x/LN2);
2366 .................... s = 0; 2366 .................... s = 0;
2367 .................... y = x; 2367 .................... y = x;
2368 .................... 2368 ....................
2369 .................... if (x < 0) 2369 .................... if (x < 0)
2370 .................... { 2370 .................... {
2371 .................... s = 1; 2371 .................... s = 1;
2372 .................... n = -n; 2372 .................... n = -n;
2373 .................... y = -y; 2373 .................... y = -y;
2374 .................... } 2374 .................... }
2375 .................... 2375 ....................
2376 .................... res = 0.0; 2376 .................... res = 0.0;
2377 .................... 2377 ....................
2378 .................... #if !defined(__PCD__) 2378 .................... #if !defined(__PCD__)
2379 .................... *((unsigned int16 *)(&res)) = n + 0x7F; 2379 .................... *((unsigned int16 *)(&res)) = n + 0x7F;
2380 .................... #endif 2380 .................... #endif
2381 .................... p= (((unsigned int16 *)(&res))+3); 2381 .................... p= (((unsigned int16 *)(&res))+3);
2382 .................... data1 = *p; 2382 .................... data1 = *p;
2383 .................... data2 = *p; 2383 .................... data2 = *p;
2384 .................... data1 = n + 0x3FF; 2384 .................... data1 = n + 0x3FF;
2385 .................... data1 = data1 <<4; 2385 .................... data1 = data1 <<4;
2386 .................... if(bit_test(data2,15)) 2386 .................... if(bit_test(data2,15))
2387 .................... bit_set(data1,15); 2387 .................... bit_set(data1,15);
2388 .................... data2 = data2 & 0x000F; 2388 .................... data2 = data2 & 0x000F;
2389 .................... data1 ^= data2; 2389 .................... data1 ^= data2;
2390 .................... 2390 ....................
2391 .................... *(((unsigned int16 *)(&res)+3)) = data1; 2391 .................... *(((unsigned int16 *)(&res)+3)) = data1;
2392 .................... 2392 ....................
2393 .................... 2393 ....................
2394 .................... y = y/LN2 - (float64)n; 2394 .................... y = y/LN2 - (float64)n;
2395 .................... 2395 ....................
2396 .................... r = pe[0]*y + pe[1]; 2396 .................... r = pe[0]*y + pe[1];
2397 .................... r = r*y + pe[2]; 2397 .................... r = r*y + pe[2];
2398 .................... r = r*y + pe[3]; 2398 .................... r = r*y + pe[3];
2399 .................... r = r*y + pe[4]; 2399 .................... r = r*y + pe[4];
2400 .................... r = r*y + pe[5]; 2400 .................... r = r*y + pe[5];
2401 .................... 2401 ....................
2402 .................... res = res*(1.0 + y*r); 2402 .................... res = res*(1.0 + y*r);
2403 .................... 2403 ....................
2404 .................... if (s) 2404 .................... if (s)
2405 .................... res = 1.0/res; 2405 .................... res = 1.0/res;
2406 .................... return(res); 2406 .................... return(res);
2407 .................... } 2407 .................... }
2408 .................... 2408 ....................
2409 .................... #ENDIF 2409 .................... #ENDIF
2410 .................... 2410 ....................
2411 .................... 2411 ....................
2412 .................... /************************************************************/ 2412 .................... /************************************************************/
2413 .................... 2413 ....................
2414 .................... float32 const pl[4] = {0.45145214, -9.0558803, 26.940971, -19.860189}; 2414 .................... float32 const pl[4] = {0.45145214, -9.0558803, 26.940971, -19.860189};
2415 .................... float32 const ql[4] = {1.0000000, -8.1354259, 16.780517, -9.9300943}; 2415 .................... float32 const ql[4] = {1.0000000, -8.1354259, 16.780517, -9.9300943};
2416 .................... 2416 ....................
2417 .................... //////////////////////////////////////////////////////////////////////////// 2417 .................... ////////////////////////////////////////////////////////////////////////////
2418 .................... // float log(float x) 2418 .................... // float log(float x)
2419 .................... //////////////////////////////////////////////////////////////////////////// 2419 .................... ////////////////////////////////////////////////////////////////////////////
2420 .................... // Description : returns the the natural log of x 2420 .................... // Description : returns the the natural log of x
2421 .................... // Date : N/A 2421 .................... // Date : N/A
2422 .................... // 2422 .................... //
2423 .................... float32 log(float32 x) 2423 .................... float32 log(float32 x)
2424 .................... { 2424 .................... {
2425 .................... float32 y, res, r, y2; 2425 .................... float32 y, res, r, y2;
2426 .................... #if defined(__PCD__) 2426 .................... #if defined(__PCD__)
2427 .................... unsigned int8 data1,data2; 2427 .................... unsigned int8 data1,data2;
2428 .................... #endif 2428 .................... #endif
2429 .................... signed int8 n; 2429 .................... signed int8 n;
2430 .................... #ifdef _ERRNO 2430 .................... #ifdef _ERRNO
2431 .................... if(x <0) 2431 .................... if(x <0)
2432 .................... { 2432 .................... {
2433 .................... errno=EDOM; 2433 .................... errno=EDOM;
2434 .................... } 2434 .................... }
2435 .................... if(x ==0) 2435 .................... if(x ==0)
2436 .................... { 2436 .................... {
2437 .................... errno=ERANGE; 2437 .................... errno=ERANGE;
2438 .................... return(0); 2438 .................... return(0);
2439 .................... } 2439 .................... }
2440 .................... #endif 2440 .................... #endif
2441 .................... y = x; 2441 .................... y = x;
2442 .................... 2442 ....................
2443 .................... if (y != 1.0) 2443 .................... if (y != 1.0)
2444 .................... { 2444 .................... {
2445 .................... #if !defined(__PCD__) 2445 .................... #if !defined(__PCD__)
2446 .................... *((unsigned int8 *)(&y)) = 0x7E; 2446 .................... *((unsigned int8 *)(&y)) = 0x7E;
2447 .................... #endif 2447 .................... #endif
2448 .................... 2448 ....................
2449 .................... #if defined(__PCD__) // Takes care of IEEE format 2449 .................... #if defined(__PCD__) // Takes care of IEEE format
2450 .................... data2 = *(((unsigned int8 *)(&y))+3); 2450 .................... data2 = *(((unsigned int8 *)(&y))+3);
2451 .................... *(((unsigned int8 *)(&y))+3) = 0x3F; 2451 .................... *(((unsigned int8 *)(&y))+3) = 0x3F;
2452 .................... data1 = *(((unsigned int8 *)(&y))+2); 2452 .................... data1 = *(((unsigned int8 *)(&y))+2);
2453 .................... bit_clear(data1,7); 2453 .................... bit_clear(data1,7);
2454 .................... *(((unsigned int8 *)(&y))+2) = data1; 2454 .................... *(((unsigned int8 *)(&y))+2) = data1;
2455 .................... if(bit_test(data2,7)) 2455 .................... if(bit_test(data2,7))
2456 .................... bit_set(*(((unsigned int8 *)(&y))+3),7); 2456 .................... bit_set(*(((unsigned int8 *)(&y))+3),7);
2457 .................... #endif 2457 .................... #endif
2458 .................... 2458 ....................
2459 .................... y = (y - 1.0)/(y + 1.0); 2459 .................... y = (y - 1.0)/(y + 1.0);
2460 .................... 2460 ....................
2461 .................... y2=y*y; 2461 .................... y2=y*y;
2462 .................... 2462 ....................
2463 .................... res = pl[0]*y2 + pl[1]; 2463 .................... res = pl[0]*y2 + pl[1];
2464 .................... res = res*y2 + pl[2]; 2464 .................... res = res*y2 + pl[2];
2465 .................... res = res*y2 + pl[3]; 2465 .................... res = res*y2 + pl[3];
2466 .................... 2466 ....................
2467 .................... r = ql[0]*y2 + ql[1]; 2467 .................... r = ql[0]*y2 + ql[1];
2468 .................... r = r*y2 + ql[2]; 2468 .................... r = r*y2 + ql[2];
2469 .................... r = r*y2 + ql[3]; 2469 .................... r = r*y2 + ql[3];
2470 .................... 2470 ....................
2471 .................... res = y*res/r; 2471 .................... res = y*res/r;
2472 .................... #if !defined(__PCD__) 2472 .................... #if !defined(__PCD__)
2473 .................... n = *((unsigned int8 *)(&x)) - 0x7E; 2473 .................... n = *((unsigned int8 *)(&x)) - 0x7E;
2474 .................... #endif 2474 .................... #endif
2475 .................... #if defined(__PCD__) 2475 .................... #if defined(__PCD__)
2476 .................... data1 = *(((unsigned int8 *)(&x)+3)); 2476 .................... data1 = *(((unsigned int8 *)(&x)+3));
2477 .................... rotate_left(&data1,1); 2477 .................... rotate_left(&data1,1);
2478 .................... data2 = *(((unsigned int8 *)(&x)+2)); 2478 .................... data2 = *(((unsigned int8 *)(&x)+2));
2479 .................... if(bit_test (data2,7)) 2479 .................... if(bit_test (data2,7))
2480 .................... bit_set(data1,0); 2480 .................... bit_set(data1,0);
2481 .................... n = data1 - 0x7E; 2481 .................... n = data1 - 0x7E;
2482 .................... #endif 2482 .................... #endif
2483 .................... 2483 ....................
2484 .................... if (n<0) 2484 .................... if (n<0)
2485 .................... r = -(float32)-n; 2485 .................... r = -(float32)-n;
2486 .................... else 2486 .................... else
2487 .................... r = (float32)n; 2487 .................... r = (float32)n;
2488 .................... 2488 ....................
2489 .................... res += r*LN2; 2489 .................... res += r*LN2;
2490 .................... } 2490 .................... }
2491 .................... 2491 ....................
2492 .................... else 2492 .................... else
2493 .................... res = 0.0; 2493 .................... res = 0.0;
2494 .................... 2494 ....................
2495 .................... return(res); 2495 .................... return(res);
2496 .................... } 2496 .................... }
2497 .................... 2497 ....................
2498 .................... //Overloaded function for log() for PCD 2498 .................... //Overloaded function for log() for PCD
2499 .................... // Overloaded function log() for data type - Float48 2499 .................... // Overloaded function log() for data type - Float48
2500 .................... #if defined(__PCD__) 2500 .................... #if defined(__PCD__)
2501 .................... float48 log(float48 x) 2501 .................... float48 log(float48 x)
2502 .................... { 2502 .................... {
2503 .................... float48 y, res, r, y2; 2503 .................... float48 y, res, r, y2;
2504 .................... unsigned int8 data1,data2; 2504 .................... unsigned int8 data1,data2;
2505 .................... signed int8 n; 2505 .................... signed int8 n;
2506 .................... #ifdef _ERRNO 2506 .................... #ifdef _ERRNO
2507 .................... if(x <0) 2507 .................... if(x <0)
2508 .................... { 2508 .................... {
2509 .................... errno=EDOM; 2509 .................... errno=EDOM;
2510 .................... } 2510 .................... }
2511 .................... if(x ==0) 2511 .................... if(x ==0)
2512 .................... { 2512 .................... {
2513 .................... errno=ERANGE; 2513 .................... errno=ERANGE;
2514 .................... return(0); 2514 .................... return(0);
2515 .................... } 2515 .................... }
2516 .................... #endif 2516 .................... #endif
2517 .................... y = x; 2517 .................... y = x;
2518 .................... 2518 ....................
2519 .................... if (y != 1.0) 2519 .................... if (y != 1.0)
2520 .................... { 2520 .................... {
2521 .................... 2521 ....................
2522 .................... #if !defined(__PCD__) 2522 .................... #if !defined(__PCD__)
2523 .................... *((unsigned int8 *)(&y)) = 0x7E; 2523 .................... *((unsigned int8 *)(&y)) = 0x7E;
2524 .................... #endif 2524 .................... #endif
2525 .................... data2 = *(((unsigned int8 *)(&y))+5); 2525 .................... data2 = *(((unsigned int8 *)(&y))+5);
2526 .................... *(((unsigned int8 *)(&y))+5) = 0x3F; 2526 .................... *(((unsigned int8 *)(&y))+5) = 0x3F;
2527 .................... data1 = *(((unsigned int8 *)(&y))+4); 2527 .................... data1 = *(((unsigned int8 *)(&y))+4);
2528 .................... bit_clear(data1,7); 2528 .................... bit_clear(data1,7);
2529 .................... *(((unsigned int8 *)(&y))+4) = data1; 2529 .................... *(((unsigned int8 *)(&y))+4) = data1;
2530 .................... 2530 ....................
2531 .................... if(bit_test(data2,7)) 2531 .................... if(bit_test(data2,7))
2532 .................... bit_set(*(((unsigned int8 *)(&y))+4),7); 2532 .................... bit_set(*(((unsigned int8 *)(&y))+4),7);
2533 .................... y = (y - 1.0)/(y + 1.0); 2533 .................... y = (y - 1.0)/(y + 1.0);
2534 .................... 2534 ....................
2535 .................... y2=y*y; 2535 .................... y2=y*y;
2536 .................... 2536 ....................
2537 .................... res = pl[0]*y2 + pl[1]; 2537 .................... res = pl[0]*y2 + pl[1];
2538 .................... res = res*y2 + pl[2]; 2538 .................... res = res*y2 + pl[2];
2539 .................... res = res*y2 + pl[3]; 2539 .................... res = res*y2 + pl[3];
2540 .................... 2540 ....................
2541 .................... r = ql[0]*y2 + ql[1]; 2541 .................... r = ql[0]*y2 + ql[1];
2542 .................... r = r*y2 + ql[2]; 2542 .................... r = r*y2 + ql[2];
2543 .................... r = r*y2 + ql[3]; 2543 .................... r = r*y2 + ql[3];
2544 .................... 2544 ....................
2545 .................... res = y*res/r; 2545 .................... res = y*res/r;
2546 .................... 2546 ....................
2547 .................... data1 = *(((unsigned int8 *)(&x)+5)); 2547 .................... data1 = *(((unsigned int8 *)(&x)+5));
2548 .................... rotate_left(&data1,1); 2548 .................... rotate_left(&data1,1);
2549 .................... data2 = *(((unsigned int8 *)(&x)+4)); 2549 .................... data2 = *(((unsigned int8 *)(&x)+4));
2550 .................... if(bit_test (data2,7)) 2550 .................... if(bit_test (data2,7))
2551 .................... bit_set(data1,0); 2551 .................... bit_set(data1,0);
2552 .................... 2552 ....................
2553 .................... n = data1 - 0x7E; 2553 .................... n = data1 - 0x7E;
2554 .................... 2554 ....................
2555 .................... if (n<0) 2555 .................... if (n<0)
2556 .................... r = -(float48)-n; 2556 .................... r = -(float48)-n;
2557 .................... else 2557 .................... else
2558 .................... r = (float48)n; 2558 .................... r = (float48)n;
2559 .................... 2559 ....................
2560 .................... res += r*LN2; 2560 .................... res += r*LN2;
2561 .................... } 2561 .................... }
2562 .................... 2562 ....................
2563 .................... else 2563 .................... else
2564 .................... res = 0.0; 2564 .................... res = 0.0;
2565 .................... 2565 ....................
2566 .................... return(res); 2566 .................... return(res);
2567 .................... } 2567 .................... }
2568 .................... 2568 ....................
2569 .................... // Overloaded function log() for data type - Float48 2569 .................... // Overloaded function log() for data type - Float48
2570 .................... #if defined(__PCD__) 2570 .................... #if defined(__PCD__)
2571 .................... float32 const pl_64[4] = {0.45145214, -9.0558803, 26.940971, -19.860189}; 2571 .................... float32 const pl_64[4] = {0.45145214, -9.0558803, 26.940971, -19.860189};
2572 .................... float32 const ql_64[4] = {1.0000000, -8.1354259, 16.780517, -9.9300943}; 2572 .................... float32 const ql_64[4] = {1.0000000, -8.1354259, 16.780517, -9.9300943};
2573 .................... #endif 2573 .................... #endif
2574 .................... float64 log(float64 x) 2574 .................... float64 log(float64 x)
2575 .................... { 2575 .................... {
2576 .................... float64 y, res, r, y2; 2576 .................... float64 y, res, r, y2;
2577 .................... unsigned int16 data1,data2; 2577 .................... unsigned int16 data1,data2;
2578 .................... unsigned int16 *p; 2578 .................... unsigned int16 *p;
2579 .................... signed int16 n; 2579 .................... signed int16 n;
2580 .................... #ifdef _ERRNO 2580 .................... #ifdef _ERRNO
2581 .................... if(x <0) 2581 .................... if(x <0)
2582 .................... { 2582 .................... {
2583 .................... errno=EDOM; 2583 .................... errno=EDOM;
2584 .................... } 2584 .................... }
2585 .................... if(x ==0) 2585 .................... if(x ==0)
2586 .................... { 2586 .................... {
2587 .................... errno=ERANGE; 2587 .................... errno=ERANGE;
2588 .................... return(0); 2588 .................... return(0);
2589 .................... } 2589 .................... }
2590 .................... #endif 2590 .................... #endif
2591 .................... y = x; 2591 .................... y = x;
2592 .................... 2592 ....................
2593 .................... if (y != 1.0) 2593 .................... if (y != 1.0)
2594 .................... { 2594 .................... {
2595 .................... #if !defined(__PCD__) 2595 .................... #if !defined(__PCD__)
2596 .................... *((unsigned int8 *)(&y)) = 0x7E; 2596 .................... *((unsigned int8 *)(&y)) = 0x7E;
2597 .................... #endif 2597 .................... #endif
2598 .................... p= (((unsigned int16 *)(&y))+3); 2598 .................... p= (((unsigned int16 *)(&y))+3);
2599 .................... data1 = *p; 2599 .................... data1 = *p;
2600 .................... data2 = *p; 2600 .................... data2 = *p;
2601 .................... data1 = 0x3FE; 2601 .................... data1 = 0x3FE;
2602 .................... data1 = data1 <<4; 2602 .................... data1 = data1 <<4;
2603 .................... if(bit_test (data2,15)) 2603 .................... if(bit_test (data2,15))
2604 .................... bit_set(data1,15); 2604 .................... bit_set(data1,15);
2605 .................... data2 = data2 & 0x000F; 2605 .................... data2 = data2 & 0x000F;
2606 .................... data1 ^=data2; 2606 .................... data1 ^=data2;
2607 .................... 2607 ....................
2608 .................... *p = data1; 2608 .................... *p = data1;
2609 .................... 2609 ....................
2610 .................... y = (y - 1.0)/(y + 1.0); 2610 .................... y = (y - 1.0)/(y + 1.0);
2611 .................... 2611 ....................
2612 .................... y2=y*y; 2612 .................... y2=y*y;
2613 .................... 2613 ....................
2614 .................... res = pl_64[0]*y2 + pl_64[1]; 2614 .................... res = pl_64[0]*y2 + pl_64[1];
2615 .................... res = res*y2 + pl_64[2]; 2615 .................... res = res*y2 + pl_64[2];
2616 .................... res = res*y2 + pl_64[3]; 2616 .................... res = res*y2 + pl_64[3];
2617 .................... 2617 ....................
2618 .................... r = ql_64[0]*y2 + ql_64[1]; 2618 .................... r = ql_64[0]*y2 + ql_64[1];
2619 .................... r = r*y2 + ql_64[2]; 2619 .................... r = r*y2 + ql_64[2];
2620 .................... r = r*y2 + ql_64[3]; 2620 .................... r = r*y2 + ql_64[3];
2621 .................... 2621 ....................
2622 .................... res = y*res/r; 2622 .................... res = y*res/r;
2623 .................... 2623 ....................
2624 .................... p= (((unsigned int16 *)(&x))+3); 2624 .................... p= (((unsigned int16 *)(&x))+3);
2625 .................... data1 = *p; 2625 .................... data1 = *p;
2626 .................... bit_clear(data1,15); 2626 .................... bit_clear(data1,15);
2627 .................... data1 = data1 >>4; 2627 .................... data1 = data1 >>4;
2628 .................... n = data1 - 0x3FE; 2628 .................... n = data1 - 0x3FE;
2629 .................... 2629 ....................
2630 .................... 2630 ....................
2631 .................... if (n<0) 2631 .................... if (n<0)
2632 .................... r = -(float64)-n; 2632 .................... r = -(float64)-n;
2633 .................... else 2633 .................... else
2634 .................... r = (float64)n; 2634 .................... r = (float64)n;
2635 .................... 2635 ....................
2636 .................... res += r*LN2; 2636 .................... res += r*LN2;
2637 .................... } 2637 .................... }
2638 .................... 2638 ....................
2639 .................... else 2639 .................... else
2640 .................... res = 0.0; 2640 .................... res = 0.0;
2641 .................... 2641 ....................
2642 .................... return(res); 2642 .................... return(res);
2643 .................... } 2643 .................... }
2644 .................... #endif 2644 .................... #endif
2645 .................... 2645 ....................
2646 .................... 2646 ....................
2647 .................... #define LN10 2.3025850929940456 2647 .................... #define LN10 2.3025850929940456
2648 .................... 2648 ....................
2649 .................... //////////////////////////////////////////////////////////////////////////// 2649 .................... ////////////////////////////////////////////////////////////////////////////
2650 .................... // float log10(float x) 2650 .................... // float log10(float x)
2651 .................... //////////////////////////////////////////////////////////////////////////// 2651 .................... ////////////////////////////////////////////////////////////////////////////
2652 .................... // Description : returns the the log base 10 of x 2652 .................... // Description : returns the the log base 10 of x
2653 .................... // Date : N/A 2653 .................... // Date : N/A
2654 .................... // 2654 .................... //
2655 .................... float32 log10(float32 x) 2655 .................... float32 log10(float32 x)
2656 .................... { 2656 .................... {
2657 .................... float32 r; 2657 .................... float32 r;
2658 .................... 2658 ....................
2659 .................... r = log(x); 2659 .................... r = log(x);
2660 .................... r = r/LN10; 2660 .................... r = r/LN10;
2661 .................... return(r); 2661 .................... return(r);
2662 .................... } 2662 .................... }
2663 .................... 2663 ....................
2664 .................... //Overloaded functions for log10() for PCD 2664 .................... //Overloaded functions for log10() for PCD
2665 .................... // Overloaded function log10() for data type - Float48 2665 .................... // Overloaded function log10() for data type - Float48
2666 .................... #if defined(__PCD__) 2666 .................... #if defined(__PCD__)
2667 .................... float48 log10(float48 x) 2667 .................... float48 log10(float48 x)
2668 .................... { 2668 .................... {
2669 .................... float48 r; 2669 .................... float48 r;
2670 .................... 2670 ....................
2671 .................... r = log(x); 2671 .................... r = log(x);
2672 .................... r = r/LN10; 2672 .................... r = r/LN10;
2673 .................... return(r); 2673 .................... return(r);
2674 .................... } 2674 .................... }
2675 .................... 2675 ....................
2676 .................... // Overloaded function log10() for data type - Float64 2676 .................... // Overloaded function log10() for data type - Float64
2677 .................... float64 log10(float64 x) 2677 .................... float64 log10(float64 x)
2678 .................... { 2678 .................... {
2679 .................... float64 r; 2679 .................... float64 r;
2680 .................... 2680 ....................
2681 .................... r = log(x); 2681 .................... r = log(x);
2682 .................... r = r/LN10; 2682 .................... r = r/LN10;
2683 .................... return(r); 2683 .................... return(r);
2684 .................... } 2684 .................... }
2685 .................... #endif 2685 .................... #endif
2686 .................... //////////////////////////////////////////////////////////////////////////// 2686 .................... ////////////////////////////////////////////////////////////////////////////
2687 .................... // float modf(float x) 2687 .................... // float modf(float x)
2688 .................... //////////////////////////////////////////////////////////////////////////// 2688 .................... ////////////////////////////////////////////////////////////////////////////
2689 .................... // Description :breaks the argument value int integral and fractional parts, 2689 .................... // Description :breaks the argument value int integral and fractional parts,
2690 .................... // ach of which have the same sign as the argument. It stores the integral part 2690 .................... // ach of which have the same sign as the argument. It stores the integral part
2691 .................... // as a float in the object pointed to by the iptr 2691 .................... // as a float in the object pointed to by the iptr
2692 .................... // Returns : returns the signed fractional part of value. 2692 .................... // Returns : returns the signed fractional part of value.
2693 .................... // Date : N/A 2693 .................... // Date : N/A
2694 .................... // 2694 .................... //
2695 .................... 2695 ....................
2696 .................... float32 modf(float32 value,float32 *iptr) 2696 .................... float32 modf(float32 value,float32 *iptr)
2697 .................... { 2697 .................... {
2698 .................... *iptr=(value < 0.0)? ceil(value): floor(value); 2698 .................... *iptr=(value < 0.0)? ceil(value): floor(value);
2699 .................... return(value - *iptr); 2699 .................... return(value - *iptr);
2700 .................... } 2700 .................... }
2701 .................... //Overloaded functions for modf() for PCD 2701 .................... //Overloaded functions for modf() for PCD
2702 .................... // Overloaded function modf() for data type - Float48 2702 .................... // Overloaded function modf() for data type - Float48
2703 .................... #if defined(__PCD__) 2703 .................... #if defined(__PCD__)
2704 .................... float48 modf(float48 value,float48 *iptr) 2704 .................... float48 modf(float48 value,float48 *iptr)
2705 .................... { 2705 .................... {
2706 .................... *iptr=(value < 0.0)? ceil(value): floor(value); 2706 .................... *iptr=(value < 0.0)? ceil(value): floor(value);
2707 .................... return(value - *iptr); 2707 .................... return(value - *iptr);
2708 .................... } 2708 .................... }
2709 .................... // Overloaded function modf() for data type - Float64 2709 .................... // Overloaded function modf() for data type - Float64
2710 .................... float64 modf(float64 value,float64 *iptr) 2710 .................... float64 modf(float64 value,float64 *iptr)
2711 .................... { 2711 .................... {
2712 .................... *iptr=(value < 0.0)? ceil(value): floor(value); 2712 .................... *iptr=(value < 0.0)? ceil(value): floor(value);
2713 .................... return(value - *iptr); 2713 .................... return(value - *iptr);
2714 .................... } 2714 .................... }
2715 .................... #endif 2715 .................... #endif
2716 .................... 2716 ....................
2717 .................... //////////////////////////////////////////////////////////////////////////// 2717 .................... ////////////////////////////////////////////////////////////////////////////
2718 .................... // float pwr(float x,float y) 2718 .................... // float pwr(float x,float y)
2719 .................... //////////////////////////////////////////////////////////////////////////// 2719 .................... ////////////////////////////////////////////////////////////////////////////
2720 .................... // Description : returns the value (x^y) 2720 .................... // Description : returns the value (x^y)
2721 .................... // Date : N/A 2721 .................... // Date : N/A
2722 .................... // Note : 0 is returned when the function will generate an imaginary number 2722 .................... // Note : 0 is returned when the function will generate an imaginary number
2723 .................... // 2723 .................... //
2724 .................... float32 pwr(float32 x,float32 y) 2724 .................... float32 pwr(float32 x,float32 y)
2725 .................... { 2725 .................... {
2726 .................... if(0 > x && fmod(y, 1) == 0) { 2726 .................... if(0 > x && fmod(y, 1) == 0) {
2727 .................... if(fmod(y, 2) == 0) { 2727 .................... if(fmod(y, 2) == 0) {
2728 .................... return (exp(log(-x) * y)); 2728 .................... return (exp(log(-x) * y));
2729 .................... } else { 2729 .................... } else {
2730 .................... return (-exp(log(-x) * y)); 2730 .................... return (-exp(log(-x) * y));
2731 .................... } 2731 .................... }
2732 .................... } else if(0 > x && fmod(y, 1) != 0) { 2732 .................... } else if(0 > x && fmod(y, 1) != 0) {
2733 .................... return 0; 2733 .................... return 0;
2734 .................... } else { 2734 .................... } else {
2735 .................... if(x != 0 || 0 >= y) { 2735 .................... if(x != 0 || 0 >= y) {
2736 .................... return (exp(log(x) * y)); 2736 .................... return (exp(log(x) * y));
2737 .................... } 2737 .................... }
2738 .................... } 2738 .................... }
2739 .................... } 2739 .................... }
2740 .................... //Overloaded functions for pwr() for PCD 2740 .................... //Overloaded functions for pwr() for PCD
2741 .................... // Overloaded function pwr() for data type - Float48 2741 .................... // Overloaded function pwr() for data type - Float48
2742 .................... #if defined(__PCD__) 2742 .................... #if defined(__PCD__)
2743 .................... float48 pwr(float48 x,float48 y) 2743 .................... float48 pwr(float48 x,float48 y)
2744 .................... { 2744 .................... {
2745 .................... if(0 > x && fmod(y, 1) == 0) { 2745 .................... if(0 > x && fmod(y, 1) == 0) {
2746 .................... if(fmod(y, 2) == 0) { 2746 .................... if(fmod(y, 2) == 0) {
2747 .................... return (exp(log(-x) * y)); 2747 .................... return (exp(log(-x) * y));
2748 .................... } else { 2748 .................... } else {
2749 .................... return (-exp(log(-x) * y)); 2749 .................... return (-exp(log(-x) * y));
2750 .................... } 2750 .................... }
2751 .................... } else if(0 > x && fmod(y, 1) != 0) { 2751 .................... } else if(0 > x && fmod(y, 1) != 0) {
2752 .................... return 0; 2752 .................... return 0;
2753 .................... } else { 2753 .................... } else {
2754 .................... if(x != 0 || 0 >= y) { 2754 .................... if(x != 0 || 0 >= y) {
2755 .................... return (exp(log(x) * y)); 2755 .................... return (exp(log(x) * y));
2756 .................... } 2756 .................... }
2757 .................... } 2757 .................... }
2758 .................... } 2758 .................... }
2759 .................... // Overloaded function pwr() for data type - Float64 2759 .................... // Overloaded function pwr() for data type - Float64
2760 .................... float64 pwr(float64 x,float64 y) 2760 .................... float64 pwr(float64 x,float64 y)
2761 .................... { 2761 .................... {
2762 .................... if(0 > x && fmod(y, 1) == 0) { 2762 .................... if(0 > x && fmod(y, 1) == 0) {
2763 .................... if(fmod(y, 2) == 0) { 2763 .................... if(fmod(y, 2) == 0) {
2764 .................... return (exp(log(-x) * y)); 2764 .................... return (exp(log(-x) * y));
2765 .................... } else { 2765 .................... } else {
2766 .................... return (-exp(log(-x) * y)); 2766 .................... return (-exp(log(-x) * y));
2767 .................... } 2767 .................... }
2768 .................... } else if(0 > x && fmod(y, 1) != 0) { 2768 .................... } else if(0 > x && fmod(y, 1) != 0) {
2769 .................... return 0; 2769 .................... return 0;
2770 .................... } else { 2770 .................... } else {
2771 .................... if(x != 0 || 0 >= y) { 2771 .................... if(x != 0 || 0 >= y) {
2772 .................... return (exp(log(x) * y)); 2772 .................... return (exp(log(x) * y));
2773 .................... } 2773 .................... }
2774 .................... } 2774 .................... }
2775 .................... } 2775 .................... }
2776 .................... #endif 2776 .................... #endif
2777 .................... 2777 ....................
2778 .................... //////////////////// Power functions //////////////////// 2778 .................... //////////////////// Power functions ////////////////////
2779 .................... 2779 ....................
2780 .................... //////////////////////////////////////////////////////////////////////////// 2780 .................... ////////////////////////////////////////////////////////////////////////////
2781 .................... // float pow(float x,float y) 2781 .................... // float pow(float x,float y)
2782 .................... //////////////////////////////////////////////////////////////////////////// 2782 .................... ////////////////////////////////////////////////////////////////////////////
2783 .................... // Description : returns the value (x^y) 2783 .................... // Description : returns the value (x^y)
2784 .................... // Date : N/A 2784 .................... // Date : N/A
2785 .................... // Note : 0 is returned when the function will generate an imaginary number 2785 .................... // Note : 0 is returned when the function will generate an imaginary number
2786 .................... // 2786 .................... //
2787 .................... float32 pow(float32 x,float32 y) 2787 .................... float32 pow(float32 x,float32 y)
2788 .................... { 2788 .................... {
2789 .................... if(0 > x && fmod(y, 1) == 0) { 2789 .................... if(0 > x && fmod(y, 1) == 0) {
2790 .................... if(fmod(y, 2) == 0) { 2790 .................... if(fmod(y, 2) == 0) {
2791 .................... return (exp(log(-x) * y)); 2791 .................... return (exp(log(-x) * y));
2792 .................... } else { 2792 .................... } else {
2793 .................... return (-exp(log(-x) * y)); 2793 .................... return (-exp(log(-x) * y));
2794 .................... } 2794 .................... }
2795 .................... } else if(0 > x && fmod(y, 1) != 0) { 2795 .................... } else if(0 > x && fmod(y, 1) != 0) {
2796 .................... return 0; 2796 .................... return 0;
2797 .................... } else { 2797 .................... } else {
2798 .................... if(x != 0 || 0 >= y) { 2798 .................... if(x != 0 || 0 >= y) {
2799 .................... return (exp(log(x) * y)); 2799 .................... return (exp(log(x) * y));
2800 .................... } 2800 .................... }
2801 .................... } 2801 .................... }
2802 .................... } 2802 .................... }
2803 .................... //Overloaded functions for pow() for PCD 2803 .................... //Overloaded functions for pow() for PCD
2804 .................... // Overloaded function for pow() data type - Float48 2804 .................... // Overloaded function for pow() data type - Float48
2805 .................... #if defined(__PCD__) 2805 .................... #if defined(__PCD__)
2806 .................... float48 pow(float48 x,float48 y) 2806 .................... float48 pow(float48 x,float48 y)
2807 .................... { 2807 .................... {
2808 .................... if(0 > x && fmod(y, 1) == 0) { 2808 .................... if(0 > x && fmod(y, 1) == 0) {
2809 .................... if(fmod(y, 2) == 0) { 2809 .................... if(fmod(y, 2) == 0) {
2810 .................... return (exp(log(-x) * y)); 2810 .................... return (exp(log(-x) * y));
2811 .................... } else { 2811 .................... } else {
2812 .................... return (-exp(log(-x) * y)); 2812 .................... return (-exp(log(-x) * y));
2813 .................... } 2813 .................... }
2814 .................... } else if(0 > x && fmod(y, 1) != 0) { 2814 .................... } else if(0 > x && fmod(y, 1) != 0) {
2815 .................... return 0; 2815 .................... return 0;
2816 .................... } else { 2816 .................... } else {
2817 .................... if(x != 0 || 0 >= y) { 2817 .................... if(x != 0 || 0 >= y) {
2818 .................... return (exp(log(x) * y)); 2818 .................... return (exp(log(x) * y));
2819 .................... } 2819 .................... }
2820 .................... } 2820 .................... }
2821 .................... } 2821 .................... }
2822 .................... 2822 ....................
2823 .................... // Overloaded function pow() for data type - Float64 2823 .................... // Overloaded function pow() for data type - Float64
2824 .................... float64 pow(float64 x,float64 y) 2824 .................... float64 pow(float64 x,float64 y)
2825 .................... { 2825 .................... {
2826 .................... if(0 > x && fmod(y, 1) == 0) { 2826 .................... if(0 > x && fmod(y, 1) == 0) {
2827 .................... if(fmod(y, 2) == 0) { 2827 .................... if(fmod(y, 2) == 0) {
2828 .................... return (exp(log(-x) * y)); 2828 .................... return (exp(log(-x) * y));
2829 .................... } else { 2829 .................... } else {
2830 .................... return (-exp(log(-x) * y)); 2830 .................... return (-exp(log(-x) * y));
2831 .................... } 2831 .................... }
2832 .................... } else if(0 > x && fmod(y, 1) != 0) { 2832 .................... } else if(0 > x && fmod(y, 1) != 0) {
2833 .................... return 0; 2833 .................... return 0;
2834 .................... } else { 2834 .................... } else {
2835 .................... if(x != 0 || 0 >= y) { 2835 .................... if(x != 0 || 0 >= y) {
2836 .................... return (exp(log(x) * y)); 2836 .................... return (exp(log(x) * y));
2837 .................... } 2837 .................... }
2838 .................... } 2838 .................... }
2839 .................... } 2839 .................... }
2840 .................... #endif 2840 .................... #endif
2841 .................... 2841 ....................
2842 .................... //////////////////////////////////////////////////////////////////////////// 2842 .................... ////////////////////////////////////////////////////////////////////////////
2843 .................... // float sqrt(float x) 2843 .................... // float sqrt(float x)
2844 .................... //////////////////////////////////////////////////////////////////////////// 2844 .................... ////////////////////////////////////////////////////////////////////////////
2845 .................... // Description : returns the square root of x 2845 .................... // Description : returns the square root of x
2846 .................... // Date : N/A 2846 .................... // Date : N/A
2847 .................... // 2847 .................... //
2848 .................... float32 sqrt(float32 x) 2848 .................... float32 sqrt(float32 x)
2849 .................... { 2849 .................... {
2850 .................... float32 y, res; 2850 .................... float32 y, res;
2851 .................... #if defined(__PCD__) 2851 .................... #if defined(__PCD__)
2852 .................... unsigned int16 data1,data2; 2852 .................... unsigned int16 data1,data2;
2853 .................... #endif 2853 .................... #endif
2854 .................... BYTE *p; 2854 .................... BYTE *p;
2855 .................... 2855 ....................
2856 .................... #ifdef _ERRNO 2856 .................... #ifdef _ERRNO
2857 .................... if(x < 0) 2857 .................... if(x < 0)
2858 .................... { 2858 .................... {
2859 .................... errno=EDOM; 2859 .................... errno=EDOM;
2860 .................... } 2860 .................... }
2861 .................... #endif 2861 .................... #endif
2862 .................... 2862 ....................
2863 .................... if( x<=0.0) 2863 .................... if( x<=0.0)
2864 .................... return(0.0); 2864 .................... return(0.0);
2865 .................... 2865 ....................
2866 .................... y=x; 2866 .................... y=x;
2867 .................... 2867 ....................
2868 .................... #if !defined(__PCD__) 2868 .................... #if !defined(__PCD__)
2869 .................... p=&y; 2869 .................... p=&y;
2870 .................... (*p)=(BYTE)((((unsigned int16)(*p)) + 127) >> 1); 2870 .................... (*p)=(BYTE)((((unsigned int16)(*p)) + 127) >> 1);
2871 .................... #endif 2871 .................... #endif
2872 .................... 2872 ....................
2873 .................... #if defined(__PCD__) 2873 .................... #if defined(__PCD__)
2874 .................... p = (((unsigned int8 *)(&y))+3); 2874 .................... p = (((unsigned int8 *)(&y))+3);
2875 .................... data1 = *(((unsigned int8 *)(&y))+3); 2875 .................... data1 = *(((unsigned int8 *)(&y))+3);
2876 .................... data2 = *(((unsigned int8 *)(&y))+2); 2876 .................... data2 = *(((unsigned int8 *)(&y))+2);
2877 .................... rotate_left(&data1,1); 2877 .................... rotate_left(&data1,1);
2878 .................... if(bit_test(data2,7)) 2878 .................... if(bit_test(data2,7))
2879 .................... bit_set(data1,0); 2879 .................... bit_set(data1,0);
2880 .................... data1 = ((data1+127) >>1); 2880 .................... data1 = ((data1+127) >>1);
2881 .................... bit_clear(data2,7); 2881 .................... bit_clear(data2,7);
2882 .................... if(bit_test(data1,0)) 2882 .................... if(bit_test(data1,0))
2883 .................... bit_set(data2,7); 2883 .................... bit_set(data2,7);
2884 .................... data1 = data1 >>1; 2884 .................... data1 = data1 >>1;
2885 .................... *(((unsigned int8 *)(&y))+3) = data1; 2885 .................... *(((unsigned int8 *)(&y))+3) = data1;
2886 .................... *(((unsigned int8 *)(&y))+2) = data2; 2886 .................... *(((unsigned int8 *)(&y))+2) = data2;
2887 .................... 2887 ....................
2888 .................... #endif 2888 .................... #endif
2889 .................... 2889 ....................
2890 .................... do { 2890 .................... do {
2891 .................... res=y; 2891 .................... res=y;
2892 .................... y+=(x/y); 2892 .................... y+=(x/y);
2893 .................... 2893 ....................
2894 .................... #if !defined(__PCD__) 2894 .................... #if !defined(__PCD__)
2895 .................... (*p)--; 2895 .................... (*p)--;
2896 .................... #endif 2896 .................... #endif
2897 .................... 2897 ....................
2898 .................... #if defined(__PCD__) 2898 .................... #if defined(__PCD__)
2899 .................... data1 = *(((unsigned int8 *)(&y))+3); 2899 .................... data1 = *(((unsigned int8 *)(&y))+3);
2900 .................... data2 = *(((unsigned int8 *)(&y))+2); 2900 .................... data2 = *(((unsigned int8 *)(&y))+2);
2901 .................... rotate_left(&data1,1); 2901 .................... rotate_left(&data1,1);
2902 .................... if(bit_test(data2,7)) 2902 .................... if(bit_test(data2,7))
2903 .................... bit_set(data1,0); 2903 .................... bit_set(data1,0);
2904 .................... data1--; 2904 .................... data1--;
2905 .................... bit_clear(data2,7); 2905 .................... bit_clear(data2,7);
2906 .................... if(bit_test(data1,0)) 2906 .................... if(bit_test(data1,0))
2907 .................... bit_set(data2,7); 2907 .................... bit_set(data2,7);
2908 .................... data1 = data1 >>1; 2908 .................... data1 = data1 >>1;
2909 .................... *(((unsigned int8 *)(&y))+3) = data1; 2909 .................... *(((unsigned int8 *)(&y))+3) = data1;
2910 .................... *(((unsigned int8 *)(&y))+2) = data2; 2910 .................... *(((unsigned int8 *)(&y))+2) = data2;
2911 .................... 2911 ....................
2912 .................... #endif 2912 .................... #endif
2913 .................... } while(res != y); 2913 .................... } while(res != y);
2914 .................... 2914 ....................
2915 .................... return(res); 2915 .................... return(res);
2916 .................... } 2916 .................... }
2917 .................... //Overloaded functions for sqrt() for PCD 2917 .................... //Overloaded functions for sqrt() for PCD
2918 .................... // Overloaded function sqrt() for data type - Float48 2918 .................... // Overloaded function sqrt() for data type - Float48
2919 .................... #if defined(__PCD__) 2919 .................... #if defined(__PCD__)
2920 .................... float48 sqrt(float48 x) 2920 .................... float48 sqrt(float48 x)
2921 .................... { 2921 .................... {
2922 .................... float48 y, res; 2922 .................... float48 y, res;
2923 .................... unsigned int16 data1,data2; 2923 .................... unsigned int16 data1,data2;
2924 .................... BYTE *p; 2924 .................... BYTE *p;
2925 .................... 2925 ....................
2926 .................... #ifdef _ERRNO 2926 .................... #ifdef _ERRNO
2927 .................... if(x < 0) 2927 .................... if(x < 0)
2928 .................... { 2928 .................... {
2929 .................... errno=EDOM; 2929 .................... errno=EDOM;
2930 .................... } 2930 .................... }
2931 .................... #endif 2931 .................... #endif
2932 .................... 2932 ....................
2933 .................... if( x<=0.0) 2933 .................... if( x<=0.0)
2934 .................... return(0.0); 2934 .................... return(0.0);
2935 .................... 2935 ....................
2936 .................... y=x; 2936 .................... y=x;
2937 .................... 2937 ....................
2938 .................... #if !defined(__PCD__) 2938 .................... #if !defined(__PCD__)
2939 .................... p=&y; 2939 .................... p=&y;
2940 .................... (*p)=(BYTE)((((unsigned int16)(*p)) + 127) >> 1); 2940 .................... (*p)=(BYTE)((((unsigned int16)(*p)) + 127) >> 1);
2941 .................... #endif 2941 .................... #endif
2942 .................... 2942 ....................
2943 .................... #if defined(__PCD__) 2943 .................... #if defined(__PCD__)
2944 .................... p = (((unsigned int8 *)(&y))+5); 2944 .................... p = (((unsigned int8 *)(&y))+5);
2945 .................... data1 = *(((unsigned int8 *)(&y))+5); 2945 .................... data1 = *(((unsigned int8 *)(&y))+5);
2946 .................... data2 = *(((unsigned int8 *)(&y))+4); 2946 .................... data2 = *(((unsigned int8 *)(&y))+4);
2947 .................... rotate_left(&data1,1); 2947 .................... rotate_left(&data1,1);
2948 .................... if(bit_test(data2,7)) 2948 .................... if(bit_test(data2,7))
2949 .................... bit_set(data1,0); 2949 .................... bit_set(data1,0);
2950 .................... data1 = ((data1+127) >>1); 2950 .................... data1 = ((data1+127) >>1);
2951 .................... bit_clear(data2,7); 2951 .................... bit_clear(data2,7);
2952 .................... if(bit_test(data1,0)) 2952 .................... if(bit_test(data1,0))
2953 .................... bit_set(data2,7); 2953 .................... bit_set(data2,7);
2954 .................... data1 = data1 >>1; 2954 .................... data1 = data1 >>1;
2955 .................... *(((unsigned int8 *)(&y))+5) = data1; 2955 .................... *(((unsigned int8 *)(&y))+5) = data1;
2956 .................... *(((unsigned int8 *)(&y))+4) = data2; 2956 .................... *(((unsigned int8 *)(&y))+4) = data2;
2957 .................... 2957 ....................
2958 .................... #endif 2958 .................... #endif
2959 .................... 2959 ....................
2960 .................... do { 2960 .................... do {
2961 .................... res=y; 2961 .................... res=y;
2962 .................... y+=(x/y); 2962 .................... y+=(x/y);
2963 .................... 2963 ....................
2964 .................... #if !defined(__PCD__) 2964 .................... #if !defined(__PCD__)
2965 .................... (*p)--; 2965 .................... (*p)--;
2966 .................... #endif 2966 .................... #endif
2967 .................... 2967 ....................
2968 .................... data1 = *(((unsigned int8 *)(&y))+5); 2968 .................... data1 = *(((unsigned int8 *)(&y))+5);
2969 .................... data2 = *(((unsigned int8 *)(&y))+4); 2969 .................... data2 = *(((unsigned int8 *)(&y))+4);
2970 .................... rotate_left(&data1,1); 2970 .................... rotate_left(&data1,1);
2971 .................... if(bit_test(data2,7)) 2971 .................... if(bit_test(data2,7))
2972 .................... bit_set(data1,0); 2972 .................... bit_set(data1,0);
2973 .................... data1--; 2973 .................... data1--;
2974 .................... bit_clear(data2,7); 2974 .................... bit_clear(data2,7);
2975 .................... if(bit_test(data1,0)) 2975 .................... if(bit_test(data1,0))
2976 .................... bit_set(data2,7); 2976 .................... bit_set(data2,7);
2977 .................... data1 = data1 >>1; 2977 .................... data1 = data1 >>1;
2978 .................... *(((unsigned int8 *)(&y))+5) = data1; 2978 .................... *(((unsigned int8 *)(&y))+5) = data1;
2979 .................... *(((unsigned int8 *)(&y))+4) = data2; 2979 .................... *(((unsigned int8 *)(&y))+4) = data2;
2980 .................... 2980 ....................
2981 .................... } while(res != y); 2981 .................... } while(res != y);
2982 .................... 2982 ....................
2983 .................... return(res); 2983 .................... return(res);
2984 .................... } 2984 .................... }
2985 .................... 2985 ....................
2986 .................... // Overloaded function sqrt() for data type - Float64 2986 .................... // Overloaded function sqrt() for data type - Float64
2987 .................... float64 sqrt(float64 x) 2987 .................... float64 sqrt(float64 x)
2988 .................... { 2988 .................... {
2989 .................... float64 y, res; 2989 .................... float64 y, res;
2990 .................... unsigned int16 *p; 2990 .................... unsigned int16 *p;
2991 .................... unsigned int16 temp1,temp2; 2991 .................... unsigned int16 temp1,temp2;
2992 .................... 2992 ....................
2993 .................... #ifdef _ERRNO 2993 .................... #ifdef _ERRNO
2994 .................... if(x < 0) 2994 .................... if(x < 0)
2995 .................... { 2995 .................... {
2996 .................... errno=EDOM; 2996 .................... errno=EDOM;
2997 .................... } 2997 .................... }
2998 .................... #endif 2998 .................... #endif
2999 .................... 2999 ....................
3000 .................... if( x<=0.0) 3000 .................... if( x<=0.0)
3001 .................... return(0.0); 3001 .................... return(0.0);
3002 .................... 3002 ....................
3003 .................... y=x; 3003 .................... y=x;
3004 .................... p= (((unsigned int16 *)(&y))+3); 3004 .................... p= (((unsigned int16 *)(&y))+3);
3005 .................... temp1 = *p; 3005 .................... temp1 = *p;
3006 .................... temp2 = *p; 3006 .................... temp2 = *p;
3007 .................... bit_clear(temp1,15); 3007 .................... bit_clear(temp1,15);
3008 .................... temp1 = (temp1>>4)+1023; 3008 .................... temp1 = (temp1>>4)+1023;
3009 .................... temp1 = temp1 >> 1; 3009 .................... temp1 = temp1 >> 1;
3010 .................... temp1 = (temp1<<4) & 0xFFF0; 3010 .................... temp1 = (temp1<<4) & 0xFFF0;
3011 .................... if(bit_test(temp2,15)) 3011 .................... if(bit_test(temp2,15))
3012 .................... bit_set(temp1,15); 3012 .................... bit_set(temp1,15);
3013 .................... temp2 = temp2 & 0x000F; 3013 .................... temp2 = temp2 & 0x000F;
3014 .................... temp1 ^= temp2; 3014 .................... temp1 ^= temp2;
3015 .................... 3015 ....................
3016 .................... (*p) = temp1; 3016 .................... (*p) = temp1;
3017 .................... 3017 ....................
3018 .................... do { 3018 .................... do {
3019 .................... res=y; 3019 .................... res=y;
3020 .................... y+=(x/y); 3020 .................... y+=(x/y);
3021 .................... temp1 = *p; 3021 .................... temp1 = *p;
3022 .................... temp2 = *p; 3022 .................... temp2 = *p;
3023 .................... bit_clear(temp1,15); 3023 .................... bit_clear(temp1,15);
3024 .................... temp1 = (temp1>>4); 3024 .................... temp1 = (temp1>>4);
3025 .................... temp1--; 3025 .................... temp1--;
3026 .................... temp1 = (temp1<<4) & 0xFFF0; 3026 .................... temp1 = (temp1<<4) & 0xFFF0;
3027 .................... if(bit_test(temp2,15)) 3027 .................... if(bit_test(temp2,15))
3028 .................... bit_set(temp1,15); 3028 .................... bit_set(temp1,15);
3029 .................... temp2 = temp2 & 0x000F; 3029 .................... temp2 = temp2 & 0x000F;
3030 .................... temp1 ^= temp2; 3030 .................... temp1 ^= temp2;
3031 .................... (*p) = temp1; 3031 .................... (*p) = temp1;
3032 .................... 3032 ....................
3033 .................... } while(res != y); 3033 .................... } while(res != y);
3034 .................... 3034 ....................
3035 .................... return(res); 3035 .................... return(res);
3036 .................... } 3036 .................... }
3037 .................... #endif 3037 .................... #endif
3038 .................... 3038 ....................
3039 .................... ////////////////////////////// Trig Functions ////////////////////////////// 3039 .................... ////////////////////////////// Trig Functions //////////////////////////////
3040 .................... #ifdef PI_DIV_BY_TWO 3040 .................... #ifdef PI_DIV_BY_TWO
3041 .................... #undef PI_DIV_BY_TWO 3041 .................... #undef PI_DIV_BY_TWO
3042 .................... #endif 3042 .................... #endif
3043 .................... #define PI_DIV_BY_TWO 1.5707963267948966 3043 .................... #define PI_DIV_BY_TWO 1.5707963267948966
3044 .................... #ifdef TWOBYPI 3044 .................... #ifdef TWOBYPI
3045 .................... #undef TWOBYPI 3045 .................... #undef TWOBYPI
3046 .................... #define TWOBYPI 0.6366197723675813 3046 .................... #define TWOBYPI 0.6366197723675813
3047 .................... #endif 3047 .................... #endif
3048 .................... //////////////////////////////////////////////////////////////////////////// 3048 .................... ////////////////////////////////////////////////////////////////////////////
3049 .................... // float cos(float x) 3049 .................... // float cos(float x)
3050 .................... //////////////////////////////////////////////////////////////////////////// 3050 .................... ////////////////////////////////////////////////////////////////////////////
3051 .................... // Description : returns the cosine value of the angle x, which is in radian 3051 .................... // Description : returns the cosine value of the angle x, which is in radian
3052 .................... // Date : 9/20/2001 3052 .................... // Date : 9/20/2001
3053 .................... // 3053 .................... //
3054 .................... float32 cos(float32 x) 3054 .................... float32 cos(float32 x)
3055 .................... { 3055 .................... {
3056 .................... float32 y, t, t2 = 1.0; 3056 .................... float32 y, t, t2 = 1.0;
3057 .................... unsigned int8 quad, i; 3057 .................... unsigned int8 quad, i;
3058 .................... float32 frac; 3058 .................... float32 frac;
3059 .................... float32 p[6] = { //by the series definition for cosine 3059 .................... float32 p[6] = { //by the series definition for cosine
3060 .................... -0.5, // sum ( ( (-1)^n * x^2n )/(2n)! ) 3060 .................... -0.5, // sum ( ( (-1)^n * x^2n )/(2n)! )
3061 .................... 0.04166666666667, 3061 .................... 0.04166666666667,
3062 .................... -0.00138888888889, 3062 .................... -0.00138888888889,
3063 .................... 0.00002480158730, 3063 .................... 0.00002480158730,
3064 .................... -0.00000027557319, 3064 .................... -0.00000027557319,
3065 .................... 0.00000000208767, 3065 .................... 0.00000000208767,
3066 .................... //-0.00000000001147, 3066 .................... //-0.00000000001147,
3067 .................... // 0.00000000000005 3067 .................... // 0.00000000000005
3068 .................... }; 3068 .................... };
3069 .................... 3069 ....................
3070 .................... if (x < 0) x = -x; // absolute value of input 3070 .................... if (x < 0) x = -x; // absolute value of input
3071 .................... 3071 ....................
3072 .................... quad = (unsigned int8)(x / PI_DIV_BY_TWO); // quadrant 3072 .................... quad = (unsigned int8)(x / PI_DIV_BY_TWO); // quadrant
3073 .................... frac = (x / PI_DIV_BY_TWO) - quad; // fractional part of input 3073 .................... frac = (x / PI_DIV_BY_TWO) - quad; // fractional part of input
3074 .................... quad = quad % 4; // quadrant (0 to 3) 3074 .................... quad = quad % 4; // quadrant (0 to 3)
3075 .................... 3075 ....................
3076 .................... if (quad == 0 || quad == 2) 3076 .................... if (quad == 0 || quad == 2)
3077 .................... t = frac * PI_DIV_BY_TWO; 3077 .................... t = frac * PI_DIV_BY_TWO;
3078 .................... else if (quad == 1) 3078 .................... else if (quad == 1)
3079 .................... t = (1-frac) * PI_DIV_BY_TWO; 3079 .................... t = (1-frac) * PI_DIV_BY_TWO;
3080 .................... else // should be 3 3080 .................... else // should be 3
3081 .................... t = (frac-1) * PI_DIV_BY_TWO; 3081 .................... t = (frac-1) * PI_DIV_BY_TWO;
3082 .................... 3082 ....................
3083 .................... y = 1.0; 3083 .................... y = 1.0;
3084 .................... t = t * t; 3084 .................... t = t * t;
3085 .................... for (i = 0; i <= 5; i++) 3085 .................... for (i = 0; i <= 5; i++)
3086 .................... { 3086 .................... {
3087 .................... t2 = t2 * t; 3087 .................... t2 = t2 * t;
3088 .................... y = y + p[i] * t2; 3088 .................... y = y + p[i] * t2;
3089 .................... } 3089 .................... }
3090 .................... 3090 ....................
3091 .................... if (quad == 2 || quad == 1) 3091 .................... if (quad == 2 || quad == 1)
3092 .................... y = -y; // correct sign 3092 .................... y = -y; // correct sign
3093 .................... 3093 ....................
3094 .................... return (y); 3094 .................... return (y);
3095 .................... } 3095 .................... }
3096 .................... 3096 ....................
3097 .................... 3097 ....................
3098 .................... //Overloaded functions for cos() for PCD 3098 .................... //Overloaded functions for cos() for PCD
3099 .................... // Overloaded function cos() for data type - Float48 3099 .................... // Overloaded function cos() for data type - Float48
3100 .................... #if defined(__PCD__) 3100 .................... #if defined(__PCD__)
3101 .................... float48 cos(float48 x) 3101 .................... float48 cos(float48 x)
3102 .................... { 3102 .................... {
3103 .................... float48 y, t, t2 = 1.0; 3103 .................... float48 y, t, t2 = 1.0;
3104 .................... unsigned int8 quad, i; 3104 .................... unsigned int8 quad, i;
3105 .................... float48 frac; 3105 .................... float48 frac;
3106 .................... float48 p[6] = { //by the series definition for cosine 3106 .................... float48 p[6] = { //by the series definition for cosine
3107 .................... -0.5, // sum ( ( (-1)^n * x^2n )/(2n)! ) 3107 .................... -0.5, // sum ( ( (-1)^n * x^2n )/(2n)! )
3108 .................... 0.04166666666667, 3108 .................... 0.04166666666667,
3109 .................... -0.00138888888889, 3109 .................... -0.00138888888889,
3110 .................... 0.00002480158730, 3110 .................... 0.00002480158730,
3111 .................... -0.00000027557319, 3111 .................... -0.00000027557319,
3112 .................... 0.00000000208767, 3112 .................... 0.00000000208767,
3113 .................... //-0.00000000001147, 3113 .................... //-0.00000000001147,
3114 .................... // 0.00000000000005 3114 .................... // 0.00000000000005
3115 .................... }; 3115 .................... };
3116 .................... 3116 ....................
3117 .................... if (x < 0) x = -x; // absolute value of input 3117 .................... if (x < 0) x = -x; // absolute value of input
3118 .................... 3118 ....................
3119 .................... quad = (unsigned int8)(x / PI_DIV_BY_TWO); // quadrant 3119 .................... quad = (unsigned int8)(x / PI_DIV_BY_TWO); // quadrant
3120 .................... frac = (x / PI_DIV_BY_TWO) - quad; // fractional part of input 3120 .................... frac = (x / PI_DIV_BY_TWO) - quad; // fractional part of input
3121 .................... quad = quad % 4; // quadrant (0 to 3) 3121 .................... quad = quad % 4; // quadrant (0 to 3)
3122 .................... 3122 ....................
3123 .................... if (quad == 0 || quad == 2) 3123 .................... if (quad == 0 || quad == 2)
3124 .................... t = frac * PI_DIV_BY_TWO; 3124 .................... t = frac * PI_DIV_BY_TWO;
3125 .................... else if (quad == 1) 3125 .................... else if (quad == 1)
3126 .................... t = (1-frac) * PI_DIV_BY_TWO; 3126 .................... t = (1-frac) * PI_DIV_BY_TWO;
3127 .................... else // should be 3 3127 .................... else // should be 3
3128 .................... t = (frac-1) * PI_DIV_BY_TWO; 3128 .................... t = (frac-1) * PI_DIV_BY_TWO;
3129 .................... 3129 ....................
3130 .................... y = 0.999999999781; 3130 .................... y = 0.999999999781;
3131 .................... t = t * t; 3131 .................... t = t * t;
3132 .................... for (i = 0; i <= 5; i++) 3132 .................... for (i = 0; i <= 5; i++)
3133 .................... { 3133 .................... {
3134 .................... t2 = t2 * t; 3134 .................... t2 = t2 * t;
3135 .................... y = y + p[i] * t2; 3135 .................... y = y + p[i] * t2;
3136 .................... } 3136 .................... }
3137 .................... 3137 ....................
3138 .................... if (quad == 2 || quad == 1) 3138 .................... if (quad == 2 || quad == 1)
3139 .................... y = -y; // correct sign 3139 .................... y = -y; // correct sign
3140 .................... 3140 ....................
3141 .................... return (y); 3141 .................... return (y);
3142 .................... } 3142 .................... }
3143 .................... 3143 ....................
3144 .................... // Overloaded function cos() for data type - Float48 3144 .................... // Overloaded function cos() for data type - Float48
3145 .................... float64 cos(float64 x) 3145 .................... float64 cos(float64 x)
3146 .................... { 3146 .................... {
3147 .................... float64 y, t, t2 = 1.0; 3147 .................... float64 y, t, t2 = 1.0;
3148 .................... unsigned int8 quad, i; 3148 .................... unsigned int8 quad, i;
3149 .................... float64 frac; 3149 .................... float64 frac;
3150 .................... float64 p[6] = { //by the series definition for cosine 3150 .................... float64 p[6] = { //by the series definition for cosine
3151 .................... -0.5, // sum ( ( (-1)^n * x^2n )/(2n)! ) 3151 .................... -0.5, // sum ( ( (-1)^n * x^2n )/(2n)! )
3152 .................... 0.04166666666667, 3152 .................... 0.04166666666667,
3153 .................... -0.00138888888889, 3153 .................... -0.00138888888889,
3154 .................... 0.00002480158730, 3154 .................... 0.00002480158730,
3155 .................... -0.00000027557319, 3155 .................... -0.00000027557319,
3156 .................... 0.00000000208767, 3156 .................... 0.00000000208767,
3157 .................... //-0.00000000001147, 3157 .................... //-0.00000000001147,
3158 .................... // 0.00000000000005 3158 .................... // 0.00000000000005
3159 .................... }; 3159 .................... };
3160 .................... 3160 ....................
3161 .................... if (x < 0) x = -x; // absolute value of input 3161 .................... if (x < 0) x = -x; // absolute value of input
3162 .................... 3162 ....................
3163 .................... quad = (unsigned int8)(x / PI_DIV_BY_TWO); // quadrant 3163 .................... quad = (unsigned int8)(x / PI_DIV_BY_TWO); // quadrant
3164 .................... frac = (x / PI_DIV_BY_TWO) - quad; // fractional part of input 3164 .................... frac = (x / PI_DIV_BY_TWO) - quad; // fractional part of input
3165 .................... quad = quad % 4; // quadrant (0 to 3) 3165 .................... quad = quad % 4; // quadrant (0 to 3)
3166 .................... 3166 ....................
3167 .................... if (quad == 0 || quad == 2) 3167 .................... if (quad == 0 || quad == 2)
3168 .................... t = frac * PI_DIV_BY_TWO; 3168 .................... t = frac * PI_DIV_BY_TWO;
3169 .................... else if (quad == 1) 3169 .................... else if (quad == 1)
3170 .................... t = (1-frac) * PI_DIV_BY_TWO; 3170 .................... t = (1-frac) * PI_DIV_BY_TWO;
3171 .................... else // should be 3 3171 .................... else // should be 3
3172 .................... t = (frac-1) * PI_DIV_BY_TWO; 3172 .................... t = (frac-1) * PI_DIV_BY_TWO;
3173 .................... 3173 ....................
3174 .................... y = 0.999999999781; 3174 .................... y = 0.999999999781;
3175 .................... t = t * t; 3175 .................... t = t * t;
3176 .................... for (i = 0; i <= 5; i++) 3176 .................... for (i = 0; i <= 5; i++)
3177 .................... { 3177 .................... {
3178 .................... t2 = t2 * t; 3178 .................... t2 = t2 * t;
3179 .................... y = y + p[i] * t2; 3179 .................... y = y + p[i] * t2;
3180 .................... } 3180 .................... }
3181 .................... 3181 ....................
3182 .................... if (quad == 2 || quad == 1) 3182 .................... if (quad == 2 || quad == 1)
3183 .................... y = -y; // correct sign 3183 .................... y = -y; // correct sign
3184 .................... 3184 ....................
3185 .................... return (y); 3185 .................... return (y);
3186 .................... } 3186 .................... }
3187 .................... 3187 ....................
3188 .................... #endif 3188 .................... #endif
3189 .................... 3189 ....................
3190 .................... //////////////////////////////////////////////////////////////////////////// 3190 .................... ////////////////////////////////////////////////////////////////////////////
3191 .................... // float sin(float x) 3191 .................... // float sin(float x)
3192 .................... //////////////////////////////////////////////////////////////////////////// 3192 .................... ////////////////////////////////////////////////////////////////////////////
3193 .................... // Description : returns the sine value of the angle x, which is in radian 3193 .................... // Description : returns the sine value of the angle x, which is in radian
3194 .................... // Date : 9/20/2001 3194 .................... // Date : 9/20/2001
3195 .................... // 3195 .................... //
3196 .................... float32 sin(float32 x) 3196 .................... float32 sin(float32 x)
3197 .................... { 3197 .................... {
3198 .................... return cos(x - PI_DIV_BY_TWO); 3198 .................... return cos(x - PI_DIV_BY_TWO);
3199 .................... } 3199 .................... }
3200 .................... 3200 ....................
3201 .................... //Overloaded functions for sin() for PCD 3201 .................... //Overloaded functions for sin() for PCD
3202 .................... // Overloaded function sin() for data type - Float48 3202 .................... // Overloaded function sin() for data type - Float48
3203 .................... #if defined(__PCD__) 3203 .................... #if defined(__PCD__)
3204 .................... float48 sin(float48 x) 3204 .................... float48 sin(float48 x)
3205 .................... { 3205 .................... {
3206 .................... return cos(x - PI_DIV_BY_TWO); 3206 .................... return cos(x - PI_DIV_BY_TWO);
3207 .................... } 3207 .................... }
3208 .................... 3208 ....................
3209 .................... // Overloaded function sin() for data type - Float48 3209 .................... // Overloaded function sin() for data type - Float48
3210 .................... float64 sin(float64 x) 3210 .................... float64 sin(float64 x)
3211 .................... { 3211 .................... {
3212 .................... return cos(x - PI_DIV_BY_TWO); 3212 .................... return cos(x - PI_DIV_BY_TWO);
3213 .................... } 3213 .................... }
3214 .................... #endif 3214 .................... #endif
3215 .................... 3215 ....................
3216 .................... //////////////////////////////////////////////////////////////////////////// 3216 .................... ////////////////////////////////////////////////////////////////////////////
3217 .................... // float tan(float x) 3217 .................... // float tan(float x)
3218 .................... //////////////////////////////////////////////////////////////////////////// 3218 .................... ////////////////////////////////////////////////////////////////////////////
3219 .................... // Description : returns the tangent value of the angle x, which is in radian 3219 .................... // Description : returns the tangent value of the angle x, which is in radian
3220 .................... // Date : 9/20/2001 3220 .................... // Date : 9/20/2001
3221 .................... // 3221 .................... //
3222 .................... float32 tan(float32 x) 3222 .................... float32 tan(float32 x)
3223 .................... { 3223 .................... {
3224 .................... float32 c, s; 3224 .................... float32 c, s;
3225 .................... 3225 ....................
3226 .................... c = cos(x); 3226 .................... c = cos(x);
3227 .................... if (c == 0.0) 3227 .................... if (c == 0.0)
3228 .................... return (1.0e+36); 3228 .................... return (1.0e+36);
3229 .................... 3229 ....................
3230 .................... s = sin(x); 3230 .................... s = sin(x);
3231 .................... return(s/c); 3231 .................... return(s/c);
3232 .................... } 3232 .................... }
3233 .................... //Overloaded functions for tan() for PCD 3233 .................... //Overloaded functions for tan() for PCD
3234 .................... // Overloaded function tan() for data type - Float48 3234 .................... // Overloaded function tan() for data type - Float48
3235 .................... #if defined(__PCD__) 3235 .................... #if defined(__PCD__)
3236 .................... float48 tan(float48 x) 3236 .................... float48 tan(float48 x)
3237 .................... { 3237 .................... {
3238 .................... float48 c, s; 3238 .................... float48 c, s;
3239 .................... 3239 ....................
3240 .................... c = cos(x); 3240 .................... c = cos(x);
3241 .................... if (c == 0.0) 3241 .................... if (c == 0.0)
3242 .................... return (1.0e+36); 3242 .................... return (1.0e+36);
3243 .................... 3243 ....................
3244 .................... s = sin(x); 3244 .................... s = sin(x);
3245 .................... return(s/c); 3245 .................... return(s/c);
3246 .................... } 3246 .................... }
3247 .................... 3247 ....................
3248 .................... // Overloaded function tan() for data type - Float48 3248 .................... // Overloaded function tan() for data type - Float48
3249 .................... float64 tan(float64 x) 3249 .................... float64 tan(float64 x)
3250 .................... { 3250 .................... {
3251 .................... float64 c, s; 3251 .................... float64 c, s;
3252 .................... 3252 ....................
3253 .................... c = cos(x); 3253 .................... c = cos(x);
3254 .................... if (c == 0.0) 3254 .................... if (c == 0.0)
3255 .................... return (1.0e+36); 3255 .................... return (1.0e+36);
3256 .................... 3256 ....................
3257 .................... s = sin(x); 3257 .................... s = sin(x);
3258 .................... return(s/c); 3258 .................... return(s/c);
3259 .................... } 3259 .................... }
3260 .................... #endif 3260 .................... #endif
3261 .................... 3261 ....................
3262 .................... float32 const pas[3] = {0.49559947, -4.6145309, 5.6036290}; 3262 .................... float32 const pas[3] = {0.49559947, -4.6145309, 5.6036290};
3263 .................... float32 const qas[3] = {1.0000000, -5.5484666, 5.6036290}; 3263 .................... float32 const qas[3] = {1.0000000, -5.5484666, 5.6036290};
3264 .................... 3264 ....................
3265 .................... float32 ASIN_COS(float32 x, unsigned int8 n) 3265 .................... float32 ASIN_COS(float32 x, unsigned int8 n)
3266 .................... { 3266 .................... {
3267 .................... float32 y, res, r, y2; 3267 .................... float32 y, res, r, y2;
3268 .................... int1 s; 3268 .................... int1 s;
3269 .................... #ifdef _ERRNO 3269 .................... #ifdef _ERRNO
3270 .................... if(x <-1 || x > 1) 3270 .................... if(x <-1 || x > 1)
3271 .................... { 3271 .................... {
3272 .................... errno=EDOM; 3272 .................... errno=EDOM;
3273 .................... } 3273 .................... }
3274 .................... #endif 3274 .................... #endif
3275 .................... s = 0; 3275 .................... s = 0;
3276 .................... y = x; 3276 .................... y = x;
3277 .................... 3277 ....................
3278 .................... if (x < 0) 3278 .................... if (x < 0)
3279 .................... { 3279 .................... {
3280 .................... s = 1; 3280 .................... s = 1;
3281 .................... y = -y; 3281 .................... y = -y;
3282 .................... } 3282 .................... }
3283 .................... 3283 ....................
3284 .................... if (y > 0.5) 3284 .................... if (y > 0.5)
3285 .................... { 3285 .................... {
3286 .................... y = sqrt((1.0 - y)/2.0); 3286 .................... y = sqrt((1.0 - y)/2.0);
3287 .................... n += 2; 3287 .................... n += 2;
3288 .................... } 3288 .................... }
3289 .................... 3289 ....................
3290 .................... y2=y*y; 3290 .................... y2=y*y;
3291 .................... 3291 ....................
3292 .................... res = pas[0]*y2 + pas[1]; 3292 .................... res = pas[0]*y2 + pas[1];
3293 .................... res = res*y2 + pas[2]; 3293 .................... res = res*y2 + pas[2];
3294 .................... 3294 ....................
3295 .................... r = qas[0]*y2 + qas[1]; 3295 .................... r = qas[0]*y2 + qas[1];
3296 .................... r = r*y2 + qas[2]; 3296 .................... r = r*y2 + qas[2];
3297 .................... 3297 ....................
3298 .................... res = y*res/r; 3298 .................... res = y*res/r;
3299 .................... 3299 ....................
3300 .................... if (n & 2) // |x| > 0.5 3300 .................... if (n & 2) // |x| > 0.5
3301 .................... res = PI_DIV_BY_TWO - 2.0*res; 3301 .................... res = PI_DIV_BY_TWO - 2.0*res;
3302 .................... if (s) 3302 .................... if (s)
3303 .................... res = -res; 3303 .................... res = -res;
3304 .................... if (n & 1) // take arccos 3304 .................... if (n & 1) // take arccos
3305 .................... res = PI_DIV_BY_TWO - res; 3305 .................... res = PI_DIV_BY_TWO - res;
3306 .................... 3306 ....................
3307 .................... return(res); 3307 .................... return(res);
3308 .................... } 3308 .................... }
3309 .................... 3309 ....................
3310 .................... //Overloaded functions for ASIN_COS() for PCD 3310 .................... //Overloaded functions for ASIN_COS() for PCD
3311 .................... // Overloaded function ASIN_COS() for data type - Float48 3311 .................... // Overloaded function ASIN_COS() for data type - Float48
3312 .................... #if defined(__PCD__) 3312 .................... #if defined(__PCD__)
3313 .................... float48 ASIN_COS(float48 x, unsigned int8 n) 3313 .................... float48 ASIN_COS(float48 x, unsigned int8 n)
3314 .................... { 3314 .................... {
3315 .................... float48 y, res, r, y2; 3315 .................... float48 y, res, r, y2;
3316 .................... int1 s; 3316 .................... int1 s;
3317 .................... #ifdef _ERRNO 3317 .................... #ifdef _ERRNO
3318 .................... if(x <-1 || x > 1) 3318 .................... if(x <-1 || x > 1)
3319 .................... { 3319 .................... {
3320 .................... errno=EDOM; 3320 .................... errno=EDOM;
3321 .................... } 3321 .................... }
3322 .................... #endif 3322 .................... #endif
3323 .................... s = 0; 3323 .................... s = 0;
3324 .................... y = x; 3324 .................... y = x;
3325 .................... 3325 ....................
3326 .................... if (x < 0) 3326 .................... if (x < 0)
3327 .................... { 3327 .................... {
3328 .................... s = 1; 3328 .................... s = 1;
3329 .................... y = -y; 3329 .................... y = -y;
3330 .................... } 3330 .................... }
3331 .................... 3331 ....................
3332 .................... if (y > 0.5) 3332 .................... if (y > 0.5)
3333 .................... { 3333 .................... {
3334 .................... y = sqrt((1.0 - y)/2.0); 3334 .................... y = sqrt((1.0 - y)/2.0);
3335 .................... n += 2; 3335 .................... n += 2;
3336 .................... } 3336 .................... }
3337 .................... 3337 ....................
3338 .................... y2=y*y; 3338 .................... y2=y*y;
3339 .................... 3339 ....................
3340 .................... res = pas[0]*y2 + pas[1]; 3340 .................... res = pas[0]*y2 + pas[1];
3341 .................... res = res*y2 + pas[2]; 3341 .................... res = res*y2 + pas[2];
3342 .................... 3342 ....................
3343 .................... r = qas[0]*y2 + qas[1]; 3343 .................... r = qas[0]*y2 + qas[1];
3344 .................... r = r*y2 + qas[2]; 3344 .................... r = r*y2 + qas[2];
3345 .................... 3345 ....................
3346 .................... res = y*res/r; 3346 .................... res = y*res/r;
3347 .................... 3347 ....................
3348 .................... if (n & 2) // |x| > 0.5 3348 .................... if (n & 2) // |x| > 0.5
3349 .................... res = PI_DIV_BY_TWO - 2.0*res; 3349 .................... res = PI_DIV_BY_TWO - 2.0*res;
3350 .................... if (s) 3350 .................... if (s)
3351 .................... res = -res; 3351 .................... res = -res;
3352 .................... if (n & 1) // take arccos 3352 .................... if (n & 1) // take arccos
3353 .................... res = PI_DIV_BY_TWO - res; 3353 .................... res = PI_DIV_BY_TWO - res;
3354 .................... 3354 ....................
3355 .................... return(res); 3355 .................... return(res);
3356 .................... } 3356 .................... }
3357 .................... 3357 ....................
3358 .................... // Overloaded function ASIN_COS() for data type - Float64 3358 .................... // Overloaded function ASIN_COS() for data type - Float64
3359 .................... float64 ASIN_COS(float64 x, unsigned int8 n) 3359 .................... float64 ASIN_COS(float64 x, unsigned int8 n)
3360 .................... { 3360 .................... {
3361 .................... float64 y, res, r, y2; 3361 .................... float64 y, res, r, y2;
3362 .................... int1 s; 3362 .................... int1 s;
3363 .................... #ifdef _ERRNO 3363 .................... #ifdef _ERRNO
3364 .................... if(x <-1 || x > 1) 3364 .................... if(x <-1 || x > 1)
3365 .................... { 3365 .................... {
3366 .................... errno=EDOM; 3366 .................... errno=EDOM;
3367 .................... } 3367 .................... }
3368 .................... #endif 3368 .................... #endif
3369 .................... s = 0; 3369 .................... s = 0;
3370 .................... y = x; 3370 .................... y = x;
3371 .................... 3371 ....................
3372 .................... if (x < 0) 3372 .................... if (x < 0)
3373 .................... { 3373 .................... {
3374 .................... s = 1; 3374 .................... s = 1;
3375 .................... y = -y; 3375 .................... y = -y;
3376 .................... } 3376 .................... }
3377 .................... 3377 ....................
3378 .................... if (y > 0.5) 3378 .................... if (y > 0.5)
3379 .................... { 3379 .................... {
3380 .................... y = sqrt((1.0 - y)/2.0); 3380 .................... y = sqrt((1.0 - y)/2.0);
3381 .................... n += 2; 3381 .................... n += 2;
3382 .................... } 3382 .................... }
3383 .................... 3383 ....................
3384 .................... y2=y*y; 3384 .................... y2=y*y;
3385 .................... 3385 ....................
3386 .................... res = pas[0]*y2 + pas[1]; 3386 .................... res = pas[0]*y2 + pas[1];
3387 .................... res = res*y2 + pas[2]; 3387 .................... res = res*y2 + pas[2];
3388 .................... 3388 ....................
3389 .................... r = qas[0]*y2 + qas[1]; 3389 .................... r = qas[0]*y2 + qas[1];
3390 .................... r = r*y2 + qas[2]; 3390 .................... r = r*y2 + qas[2];
3391 .................... 3391 ....................
3392 .................... res = y*res/r; 3392 .................... res = y*res/r;
3393 .................... 3393 ....................
3394 .................... if (n & 2) // |x| > 0.5 3394 .................... if (n & 2) // |x| > 0.5
3395 .................... res = PI_DIV_BY_TWO - 2.0*res; 3395 .................... res = PI_DIV_BY_TWO - 2.0*res;
3396 .................... if (s) 3396 .................... if (s)
3397 .................... res = -res; 3397 .................... res = -res;
3398 .................... if (n & 1) // take arccos 3398 .................... if (n & 1) // take arccos
3399 .................... res = PI_DIV_BY_TWO - res; 3399 .................... res = PI_DIV_BY_TWO - res;
3400 .................... 3400 ....................
3401 .................... return(res); 3401 .................... return(res);
3402 .................... } 3402 .................... }
3403 .................... #endif 3403 .................... #endif
3404 .................... 3404 ....................
3405 .................... //////////////////////////////////////////////////////////////////////////// 3405 .................... ////////////////////////////////////////////////////////////////////////////
3406 .................... // float asin(float x) 3406 .................... // float asin(float x)
3407 .................... //////////////////////////////////////////////////////////////////////////// 3407 .................... ////////////////////////////////////////////////////////////////////////////
3408 .................... // Description : returns the arcsine value of the value x. 3408 .................... // Description : returns the arcsine value of the value x.
3409 .................... // Date : N/A 3409 .................... // Date : N/A
3410 .................... // 3410 .................... //
3411 .................... float32 asin(float32 x) 3411 .................... float32 asin(float32 x)
3412 .................... { 3412 .................... {
3413 .................... float32 r; 3413 .................... float32 r;
3414 .................... 3414 ....................
3415 .................... r = ASIN_COS(x, 0); 3415 .................... r = ASIN_COS(x, 0);
3416 .................... return(r); 3416 .................... return(r);
3417 .................... } 3417 .................... }
3418 .................... //Overloaded functions for asin() for PCD 3418 .................... //Overloaded functions for asin() for PCD
3419 .................... // Overloaded function asin() for data type - Float48 3419 .................... // Overloaded function asin() for data type - Float48
3420 .................... #if defined(__PCD__) 3420 .................... #if defined(__PCD__)
3421 .................... float48 asin(float48 x) 3421 .................... float48 asin(float48 x)
3422 .................... { 3422 .................... {
3423 .................... float48 r; 3423 .................... float48 r;
3424 .................... 3424 ....................
3425 .................... r = ASIN_COS(x, 0); 3425 .................... r = ASIN_COS(x, 0);
3426 .................... return(r); 3426 .................... return(r);
3427 .................... } 3427 .................... }
3428 .................... 3428 ....................
3429 .................... // Overloaded function asin() for data type - Float64 3429 .................... // Overloaded function asin() for data type - Float64
3430 .................... float64 asin(float64 x) 3430 .................... float64 asin(float64 x)
3431 .................... { 3431 .................... {
3432 .................... float64 r; 3432 .................... float64 r;
3433 .................... 3433 ....................
3434 .................... r = ASIN_COS(x, 0); 3434 .................... r = ASIN_COS(x, 0);
3435 .................... return(r); 3435 .................... return(r);
3436 .................... } 3436 .................... }
3437 .................... #endif 3437 .................... #endif
3438 .................... 3438 ....................
3439 .................... //////////////////////////////////////////////////////////////////////////// 3439 .................... ////////////////////////////////////////////////////////////////////////////
3440 .................... // float acos(float x) 3440 .................... // float acos(float x)
3441 .................... //////////////////////////////////////////////////////////////////////////// 3441 .................... ////////////////////////////////////////////////////////////////////////////
3442 .................... // Description : returns the arccosine value of the value x. 3442 .................... // Description : returns the arccosine value of the value x.
3443 .................... // Date : N/A 3443 .................... // Date : N/A
3444 .................... // 3444 .................... //
3445 .................... float32 acos(float32 x) 3445 .................... float32 acos(float32 x)
3446 .................... { 3446 .................... {
3447 .................... float32 r; 3447 .................... float32 r;
3448 .................... 3448 ....................
3449 .................... r = ASIN_COS(x, 1); 3449 .................... r = ASIN_COS(x, 1);
3450 .................... return(r); 3450 .................... return(r);
3451 .................... } 3451 .................... }
3452 .................... //Overloaded functions for acos() for PCD 3452 .................... //Overloaded functions for acos() for PCD
3453 .................... // Overloaded function acos() for data type - Float48 3453 .................... // Overloaded function acos() for data type - Float48
3454 .................... #if defined(__PCD__) 3454 .................... #if defined(__PCD__)
3455 .................... float48 acos(float48 x) 3455 .................... float48 acos(float48 x)
3456 .................... { 3456 .................... {
3457 .................... float48 r; 3457 .................... float48 r;
3458 .................... 3458 ....................
3459 .................... r = ASIN_COS(x, 1); 3459 .................... r = ASIN_COS(x, 1);
3460 .................... return(r); 3460 .................... return(r);
3461 .................... } 3461 .................... }
3462 .................... 3462 ....................
3463 .................... // Overloaded function acos() for data type - Float64 3463 .................... // Overloaded function acos() for data type - Float64
3464 .................... float64 acos(float64 x) 3464 .................... float64 acos(float64 x)
3465 .................... { 3465 .................... {
3466 .................... float64 r; 3466 .................... float64 r;
3467 .................... 3467 ....................
3468 .................... r = ASIN_COS(x, 1); 3468 .................... r = ASIN_COS(x, 1);
3469 .................... return(r); 3469 .................... return(r);
3470 .................... } 3470 .................... }
3471 .................... #endif 3471 .................... #endif
3472 .................... 3472 ....................
3473 .................... float32 const pat[4] = {0.17630401, 5.6710795, 22.376096, 19.818457}; 3473 .................... float32 const pat[4] = {0.17630401, 5.6710795, 22.376096, 19.818457};
3474 .................... float32 const qat[4] = {1.0000000, 11.368190, 28.982246, 19.818457}; 3474 .................... float32 const qat[4] = {1.0000000, 11.368190, 28.982246, 19.818457};
3475 .................... 3475 ....................
3476 .................... //////////////////////////////////////////////////////////////////////////// 3476 .................... ////////////////////////////////////////////////////////////////////////////
3477 .................... // float atan(float x) 3477 .................... // float atan(float x)
3478 .................... //////////////////////////////////////////////////////////////////////////// 3478 .................... ////////////////////////////////////////////////////////////////////////////
3479 .................... // Description : returns the arctangent value of the value x. 3479 .................... // Description : returns the arctangent value of the value x.
3480 .................... // Date : N/A 3480 .................... // Date : N/A
3481 .................... // 3481 .................... //
3482 .................... float32 atan(float32 x) 3482 .................... float32 atan(float32 x)
3483 .................... { 3483 .................... {
3484 .................... float32 y, res, r; 3484 .................... float32 y, res, r;
3485 .................... int1 s, flag; 3485 .................... int1 s, flag;
3486 .................... 3486 ....................
3487 .................... s = 0; 3487 .................... s = 0;
3488 .................... flag = 0; 3488 .................... flag = 0;
3489 .................... y = x; 3489 .................... y = x;
3490 .................... 3490 ....................
3491 .................... if (x < 0) 3491 .................... if (x < 0)
3492 .................... { 3492 .................... {
3493 .................... s = 1; 3493 .................... s = 1;
3494 .................... y = -y; 3494 .................... y = -y;
3495 .................... } 3495 .................... }
3496 .................... 3496 ....................
3497 .................... if (y > 1.0) 3497 .................... if (y > 1.0)
3498 .................... { 3498 .................... {
3499 .................... y = 1.0/y; 3499 .................... y = 1.0/y;
3500 .................... flag = 1; 3500 .................... flag = 1;
3501 .................... } 3501 .................... }
3502 .................... 3502 ....................
3503 .................... res = pat[0]*y*y + pat[1]; 3503 .................... res = pat[0]*y*y + pat[1];
3504 .................... res = res*y*y + pat[2]; 3504 .................... res = res*y*y + pat[2];
3505 .................... res = res*y*y + pat[3]; 3505 .................... res = res*y*y + pat[3];
3506 .................... 3506 ....................
3507 .................... r = qat[0]*y*y + qat[1]; 3507 .................... r = qat[0]*y*y + qat[1];
3508 .................... r = r*y*y + qat[2]; 3508 .................... r = r*y*y + qat[2];
3509 .................... r = r*y*y + qat[3]; 3509 .................... r = r*y*y + qat[3];
3510 .................... 3510 ....................
3511 .................... res = y*res/r; 3511 .................... res = y*res/r;
3512 .................... 3512 ....................
3513 .................... 3513 ....................
3514 .................... if (flag) // for |x| > 1 3514 .................... if (flag) // for |x| > 1
3515 .................... res = PI_DIV_BY_TWO - res; 3515 .................... res = PI_DIV_BY_TWO - res;
3516 .................... if (s) 3516 .................... if (s)
3517 .................... res = -res; 3517 .................... res = -res;
3518 .................... 3518 ....................
3519 .................... return(res); 3519 .................... return(res);
3520 .................... } 3520 .................... }
3521 .................... //Overloaded functions for atan() for PCD 3521 .................... //Overloaded functions for atan() for PCD
3522 .................... // Overloaded function atan() for data type - Float48 3522 .................... // Overloaded function atan() for data type - Float48
3523 .................... #if defined(__PCD__) 3523 .................... #if defined(__PCD__)
3524 .................... float48 atan(float48 x) 3524 .................... float48 atan(float48 x)
3525 .................... { 3525 .................... {
3526 .................... float48 y, res, r; 3526 .................... float48 y, res, r;
3527 .................... int1 s, flag; 3527 .................... int1 s, flag;
3528 .................... 3528 ....................
3529 .................... s = 0; 3529 .................... s = 0;
3530 .................... flag = 0; 3530 .................... flag = 0;
3531 .................... y = x; 3531 .................... y = x;
3532 .................... 3532 ....................
3533 .................... if (x < 0) 3533 .................... if (x < 0)
3534 .................... { 3534 .................... {
3535 .................... s = 1; 3535 .................... s = 1;
3536 .................... y = -y; 3536 .................... y = -y;
3537 .................... } 3537 .................... }
3538 .................... 3538 ....................
3539 .................... if (y > 1.0) 3539 .................... if (y > 1.0)
3540 .................... { 3540 .................... {
3541 .................... y = 1.0/y; 3541 .................... y = 1.0/y;
3542 .................... flag = 1; 3542 .................... flag = 1;
3543 .................... } 3543 .................... }
3544 .................... 3544 ....................
3545 .................... res = pat[0]*y*y + pat[1]; 3545 .................... res = pat[0]*y*y + pat[1];
3546 .................... res = res*y*y + pat[2]; 3546 .................... res = res*y*y + pat[2];
3547 .................... res = res*y*y + pat[3]; 3547 .................... res = res*y*y + pat[3];
3548 .................... 3548 ....................
3549 .................... r = qat[0]*y*y + qat[1]; 3549 .................... r = qat[0]*y*y + qat[1];
3550 .................... r = r*y*y + qat[2]; 3550 .................... r = r*y*y + qat[2];
3551 .................... r = r*y*y + qat[3]; 3551 .................... r = r*y*y + qat[3];
3552 .................... 3552 ....................
3553 .................... res = y*res/r; 3553 .................... res = y*res/r;
3554 .................... 3554 ....................
3555 .................... 3555 ....................
3556 .................... if (flag) // for |x| > 1 3556 .................... if (flag) // for |x| > 1
3557 .................... res = PI_DIV_BY_TWO - res; 3557 .................... res = PI_DIV_BY_TWO - res;
3558 .................... if (s) 3558 .................... if (s)
3559 .................... res = -res; 3559 .................... res = -res;
3560 .................... 3560 ....................
3561 .................... return(res); 3561 .................... return(res);
3562 .................... } 3562 .................... }
3563 .................... 3563 ....................
3564 .................... // Overloaded function atan() for data type - Float64 3564 .................... // Overloaded function atan() for data type - Float64
3565 .................... float64 atan(float64 x) 3565 .................... float64 atan(float64 x)
3566 .................... { 3566 .................... {
3567 .................... float64 y, res, r; 3567 .................... float64 y, res, r;
3568 .................... int1 s, flag; 3568 .................... int1 s, flag;
3569 .................... 3569 ....................
3570 .................... s = 0; 3570 .................... s = 0;
3571 .................... flag = 0; 3571 .................... flag = 0;
3572 .................... y = x; 3572 .................... y = x;
3573 .................... 3573 ....................
3574 .................... if (x < 0) 3574 .................... if (x < 0)
3575 .................... { 3575 .................... {
3576 .................... s = 1; 3576 .................... s = 1;
3577 .................... y = -y; 3577 .................... y = -y;
3578 .................... } 3578 .................... }
3579 .................... 3579 ....................
3580 .................... if (y > 1.0) 3580 .................... if (y > 1.0)
3581 .................... { 3581 .................... {
3582 .................... y = 1.0/y; 3582 .................... y = 1.0/y;
3583 .................... flag = 1; 3583 .................... flag = 1;
3584 .................... } 3584 .................... }
3585 .................... 3585 ....................
3586 .................... res = pat[0]*y*y + pat[1]; 3586 .................... res = pat[0]*y*y + pat[1];
3587 .................... res = res*y*y + pat[2]; 3587 .................... res = res*y*y + pat[2];
3588 .................... res = res*y*y + pat[3]; 3588 .................... res = res*y*y + pat[3];
3589 .................... 3589 ....................
3590 .................... r = qat[0]*y*y + qat[1]; 3590 .................... r = qat[0]*y*y + qat[1];
3591 .................... r = r*y*y + qat[2]; 3591 .................... r = r*y*y + qat[2];
3592 .................... r = r*y*y + qat[3]; 3592 .................... r = r*y*y + qat[3];
3593 .................... 3593 ....................
3594 .................... res = y*res/r; 3594 .................... res = y*res/r;
3595 .................... 3595 ....................
3596 .................... 3596 ....................
3597 .................... if (flag) // for |x| > 1 3597 .................... if (flag) // for |x| > 1
3598 .................... res = PI_DIV_BY_TWO - res; 3598 .................... res = PI_DIV_BY_TWO - res;
3599 .................... if (s) 3599 .................... if (s)
3600 .................... res = -res; 3600 .................... res = -res;
3601 .................... 3601 ....................
3602 .................... return(res); 3602 .................... return(res);
3603 .................... } 3603 .................... }
3604 .................... #endif 3604 .................... #endif
3605 .................... 3605 ....................
3606 .................... ///////////////////////////////////////////////////////////////////////////// 3606 .................... /////////////////////////////////////////////////////////////////////////////
3607 .................... // float atan2(float y, float x) 3607 .................... // float atan2(float y, float x)
3608 .................... ///////////////////////////////////////////////////////////////////////////// 3608 .................... /////////////////////////////////////////////////////////////////////////////
3609 .................... // Description :computes the principal value of arc tangent of y/x, using the 3609 .................... // Description :computes the principal value of arc tangent of y/x, using the
3610 .................... // signs of both the arguments to determine the quadrant of the return value 3610 .................... // signs of both the arguments to determine the quadrant of the return value
3611 .................... // Returns : returns the arc tangent of y/x. 3611 .................... // Returns : returns the arc tangent of y/x.
3612 .................... // Date : N/A 3612 .................... // Date : N/A
3613 .................... // 3613 .................... //
3614 .................... 3614 ....................
3615 .................... float32 atan2(float32 y,float32 x) 3615 .................... float32 atan2(float32 y,float32 x)
3616 .................... { 3616 .................... {
3617 .................... float32 z; 3617 .................... float32 z;
3618 .................... int1 sign; 3618 .................... int1 sign;
3619 .................... unsigned int8 quad; 3619 .................... unsigned int8 quad;
3620 .................... sign=0; 3620 .................... sign=0;
3621 .................... quad=0; //quadrant 3621 .................... quad=0; //quadrant
3622 .................... quad=((y<=0.0)?((x<=0.0)?3:4):((x<0.0)?2:1)); 3622 .................... quad=((y<=0.0)?((x<=0.0)?3:4):((x<0.0)?2:1));
3623 .................... if(y<0.0) 3623 .................... if(y<0.0)
3624 .................... { 3624 .................... {
3625 .................... sign=1; 3625 .................... sign=1;
3626 .................... y=-y; 3626 .................... y=-y;
3627 .................... } 3627 .................... }
3628 .................... if(x<0.0) 3628 .................... if(x<0.0)
3629 .................... { 3629 .................... {
3630 .................... x=-x; 3630 .................... x=-x;
3631 .................... } 3631 .................... }
3632 .................... if (x==0.0) 3632 .................... if (x==0.0)
3633 .................... { 3633 .................... {
3634 .................... if(y==0.0) 3634 .................... if(y==0.0)
3635 .................... { 3635 .................... {
3636 .................... #ifdef _ERRNO 3636 .................... #ifdef _ERRNO
3637 .................... { 3637 .................... {
3638 .................... errno=EDOM; 3638 .................... errno=EDOM;
3639 .................... } 3639 .................... }
3640 .................... #endif 3640 .................... #endif
3641 .................... } 3641 .................... }
3642 .................... else 3642 .................... else
3643 .................... { 3643 .................... {
3644 .................... if(sign) 3644 .................... if(sign)
3645 .................... { 3645 .................... {
3646 .................... return (-(PI_DIV_BY_TWO)); 3646 .................... return (-(PI_DIV_BY_TWO));
3647 .................... } 3647 .................... }
3648 .................... else 3648 .................... else
3649 .................... { 3649 .................... {
3650 .................... return (PI_DIV_BY_TWO); 3650 .................... return (PI_DIV_BY_TWO);
3651 .................... } 3651 .................... }
3652 .................... } 3652 .................... }
3653 .................... } 3653 .................... }
3654 .................... else 3654 .................... else
3655 .................... { 3655 .................... {
3656 .................... z=y/x; 3656 .................... z=y/x;
3657 .................... switch(quad) 3657 .................... switch(quad)
3658 .................... { 3658 .................... {
3659 .................... case 1: 3659 .................... case 1:
3660 .................... { 3660 .................... {
3661 .................... return atan(z); 3661 .................... return atan(z);
3662 .................... break; 3662 .................... break;
3663 .................... } 3663 .................... }
3664 .................... case 2: 3664 .................... case 2:
3665 .................... { 3665 .................... {
3666 .................... // return (atan(z)+PI_DIV_BY_TWO); //2L3122 3666 .................... // return (atan(z)+PI_DIV_BY_TWO); //2L3122
3667 .................... return (PI-atan(z)); 3667 .................... return (PI-atan(z));
3668 .................... break; 3668 .................... break;
3669 .................... } 3669 .................... }
3670 .................... case 3: 3670 .................... case 3:
3671 .................... { 3671 .................... {
3672 .................... return (atan(z)-PI); 3672 .................... return (atan(z)-PI);
3673 .................... break; 3673 .................... break;
3674 .................... } 3674 .................... }
3675 .................... case 4: 3675 .................... case 4:
3676 .................... { 3676 .................... {
3677 .................... return (-atan(z)); 3677 .................... return (-atan(z));
3678 .................... break; 3678 .................... break;
3679 .................... } 3679 .................... }
3680 .................... } 3680 .................... }
3681 .................... } 3681 .................... }
3682 .................... } 3682 .................... }
3683 .................... 3683 ....................
3684 .................... //Overloaded functions for atan2() for PCD 3684 .................... //Overloaded functions for atan2() for PCD
3685 .................... // Overloaded function atan2() for data type - Float48 3685 .................... // Overloaded function atan2() for data type - Float48
3686 .................... #if defined(__PCD__) 3686 .................... #if defined(__PCD__)
3687 .................... float48 atan2(float48 y,float48 x) 3687 .................... float48 atan2(float48 y,float48 x)
3688 .................... { 3688 .................... {
3689 .................... float48 z; 3689 .................... float48 z;
3690 .................... int1 sign; 3690 .................... int1 sign;
3691 .................... unsigned int8 quad; 3691 .................... unsigned int8 quad;
3692 .................... sign=0; 3692 .................... sign=0;
3693 .................... quad=0; //quadrant 3693 .................... quad=0; //quadrant
3694 .................... quad=((y<=0.0)?((x<=0.0)?3:4):((x<0.0)?2:1)); 3694 .................... quad=((y<=0.0)?((x<=0.0)?3:4):((x<0.0)?2:1));
3695 .................... if(y<0.0) 3695 .................... if(y<0.0)
3696 .................... { 3696 .................... {
3697 .................... sign=1; 3697 .................... sign=1;
3698 .................... y=-y; 3698 .................... y=-y;
3699 .................... } 3699 .................... }
3700 .................... if(x<0.0) 3700 .................... if(x<0.0)
3701 .................... { 3701 .................... {
3702 .................... x=-x; 3702 .................... x=-x;
3703 .................... } 3703 .................... }
3704 .................... if (x==0.0) 3704 .................... if (x==0.0)
3705 .................... { 3705 .................... {
3706 .................... if(y==0.0) 3706 .................... if(y==0.0)
3707 .................... { 3707 .................... {
3708 .................... #ifdef _ERRNO 3708 .................... #ifdef _ERRNO
3709 .................... { 3709 .................... {
3710 .................... errno=EDOM; 3710 .................... errno=EDOM;
3711 .................... } 3711 .................... }
3712 .................... #endif 3712 .................... #endif
3713 .................... } 3713 .................... }
3714 .................... else 3714 .................... else
3715 .................... { 3715 .................... {
3716 .................... if(sign) 3716 .................... if(sign)
3717 .................... { 3717 .................... {
3718 .................... return (-(PI_DIV_BY_TWO)); 3718 .................... return (-(PI_DIV_BY_TWO));
3719 .................... } 3719 .................... }
3720 .................... else 3720 .................... else
3721 .................... { 3721 .................... {
3722 .................... return (PI_DIV_BY_TWO); 3722 .................... return (PI_DIV_BY_TWO);
3723 .................... } 3723 .................... }
3724 .................... } 3724 .................... }
3725 .................... } 3725 .................... }
3726 .................... else 3726 .................... else
3727 .................... { 3727 .................... {
3728 .................... z=y/x; 3728 .................... z=y/x;
3729 .................... switch(quad) 3729 .................... switch(quad)
3730 .................... { 3730 .................... {
3731 .................... case 1: 3731 .................... case 1:
3732 .................... { 3732 .................... {
3733 .................... return atan(z); 3733 .................... return atan(z);
3734 .................... break; 3734 .................... break;
3735 .................... } 3735 .................... }
3736 .................... case 2: 3736 .................... case 2:
3737 .................... { 3737 .................... {
3738 .................... // return (atan(z)+PI_DIV_BY_TWO); //2L3122 3738 .................... // return (atan(z)+PI_DIV_BY_TWO); //2L3122
3739 .................... return (PI-atan(z)); 3739 .................... return (PI-atan(z));
3740 .................... break; 3740 .................... break;
3741 .................... } 3741 .................... }
3742 .................... case 3: 3742 .................... case 3:
3743 .................... { 3743 .................... {
3744 .................... return (atan(z)-PI); 3744 .................... return (atan(z)-PI);
3745 .................... break; 3745 .................... break;
3746 .................... } 3746 .................... }
3747 .................... case 4: 3747 .................... case 4:
3748 .................... { 3748 .................... {
3749 .................... return (-atan(z)); 3749 .................... return (-atan(z));
3750 .................... break; 3750 .................... break;
3751 .................... } 3751 .................... }
3752 .................... } 3752 .................... }
3753 .................... } 3753 .................... }
3754 .................... } 3754 .................... }
3755 .................... 3755 ....................
3756 .................... // Overloaded function atan2() for data type - Float64 3756 .................... // Overloaded function atan2() for data type - Float64
3757 .................... float64 atan2(float64 y,float64 x) 3757 .................... float64 atan2(float64 y,float64 x)
3758 .................... { 3758 .................... {
3759 .................... float64 z; 3759 .................... float64 z;
3760 .................... int1 sign; 3760 .................... int1 sign;
3761 .................... unsigned int8 quad; 3761 .................... unsigned int8 quad;
3762 .................... sign=0; 3762 .................... sign=0;
3763 .................... quad=0; //quadrant 3763 .................... quad=0; //quadrant
3764 .................... quad=((y<=0.0)?((x<=0.0)?3:4):((x<0.0)?2:1)); 3764 .................... quad=((y<=0.0)?((x<=0.0)?3:4):((x<0.0)?2:1));
3765 .................... if(y<0.0) 3765 .................... if(y<0.0)
3766 .................... { 3766 .................... {
3767 .................... sign=1; 3767 .................... sign=1;
3768 .................... y=-y; 3768 .................... y=-y;
3769 .................... } 3769 .................... }
3770 .................... if(x<0.0) 3770 .................... if(x<0.0)
3771 .................... { 3771 .................... {
3772 .................... x=-x; 3772 .................... x=-x;
3773 .................... } 3773 .................... }
3774 .................... if (x==0.0) 3774 .................... if (x==0.0)
3775 .................... { 3775 .................... {
3776 .................... if(y==0.0) 3776 .................... if(y==0.0)
3777 .................... { 3777 .................... {
3778 .................... #ifdef _ERRNO 3778 .................... #ifdef _ERRNO
3779 .................... { 3779 .................... {
3780 .................... errno=EDOM; 3780 .................... errno=EDOM;
3781 .................... } 3781 .................... }
3782 .................... #endif 3782 .................... #endif
3783 .................... } 3783 .................... }
3784 .................... else 3784 .................... else
3785 .................... { 3785 .................... {
3786 .................... if(sign) 3786 .................... if(sign)
3787 .................... { 3787 .................... {
3788 .................... return (-(PI_DIV_BY_TWO)); 3788 .................... return (-(PI_DIV_BY_TWO));
3789 .................... } 3789 .................... }
3790 .................... else 3790 .................... else
3791 .................... { 3791 .................... {
3792 .................... return (PI_DIV_BY_TWO); 3792 .................... return (PI_DIV_BY_TWO);
3793 .................... } 3793 .................... }
3794 .................... } 3794 .................... }
3795 .................... } 3795 .................... }
3796 .................... else 3796 .................... else
3797 .................... { 3797 .................... {
3798 .................... z=y/x; 3798 .................... z=y/x;
3799 .................... switch(quad) 3799 .................... switch(quad)
3800 .................... { 3800 .................... {
3801 .................... case 1: 3801 .................... case 1:
3802 .................... { 3802 .................... {
3803 .................... return atan(z); 3803 .................... return atan(z);
3804 .................... break; 3804 .................... break;
3805 .................... } 3805 .................... }
3806 .................... case 2: 3806 .................... case 2:
3807 .................... { 3807 .................... {
3808 .................... // return (atan(z)+PI_DIV_BY_TWO); //2L3122 3808 .................... // return (atan(z)+PI_DIV_BY_TWO); //2L3122
3809 .................... return (PI-atan(z)); 3809 .................... return (PI-atan(z));
3810 .................... break; 3810 .................... break;
3811 .................... } 3811 .................... }
3812 .................... case 3: 3812 .................... case 3:
3813 .................... { 3813 .................... {
3814 .................... return (atan(z)-PI); 3814 .................... return (atan(z)-PI);
3815 .................... break; 3815 .................... break;
3816 .................... } 3816 .................... }
3817 .................... case 4: 3817 .................... case 4:
3818 .................... { 3818 .................... {
3819 .................... return (-atan(z)); 3819 .................... return (-atan(z));
3820 .................... break; 3820 .................... break;
3821 .................... } 3821 .................... }
3822 .................... } 3822 .................... }
3823 .................... } 3823 .................... }
3824 .................... } 3824 .................... }
3825 .................... #endif 3825 .................... #endif
3826 .................... 3826 ....................
3827 .................... //////////////////// Hyperbolic functions //////////////////// 3827 .................... //////////////////// Hyperbolic functions ////////////////////
3828 .................... 3828 ....................
3829 .................... //////////////////////////////////////////////////////////////////////////// 3829 .................... ////////////////////////////////////////////////////////////////////////////
3830 .................... // float cosh(float x) 3830 .................... // float cosh(float x)
3831 .................... //////////////////////////////////////////////////////////////////////////// 3831 .................... ////////////////////////////////////////////////////////////////////////////
3832 .................... // Description : Computes the hyperbolic cosine value of x 3832 .................... // Description : Computes the hyperbolic cosine value of x
3833 .................... // Returns : returns the hyperbolic cosine value of x 3833 .................... // Returns : returns the hyperbolic cosine value of x
3834 .................... // Date : N/A 3834 .................... // Date : N/A
3835 .................... // 3835 .................... //
3836 .................... 3836 ....................
3837 .................... float32 cosh(float32 x) 3837 .................... float32 cosh(float32 x)
3838 .................... { 3838 .................... {
3839 .................... return ((exp(x)+exp(-x))/2); 3839 .................... return ((exp(x)+exp(-x))/2);
3840 .................... } 3840 .................... }
3841 .................... //Overloaded functions for cosh() for PCD 3841 .................... //Overloaded functions for cosh() for PCD
3842 .................... // Overloaded function cosh() for data type - Float48 3842 .................... // Overloaded function cosh() for data type - Float48
3843 .................... #if defined(__PCD__) 3843 .................... #if defined(__PCD__)
3844 .................... float48 cosh(float48 x) 3844 .................... float48 cosh(float48 x)
3845 .................... { 3845 .................... {
3846 .................... return ((exp(x)+exp(-x))/2); 3846 .................... return ((exp(x)+exp(-x))/2);
3847 .................... } 3847 .................... }
3848 .................... 3848 ....................
3849 .................... // Overloaded function cosh() for data type - Float64 3849 .................... // Overloaded function cosh() for data type - Float64
3850 .................... float64 cosh(float64 x) 3850 .................... float64 cosh(float64 x)
3851 .................... { 3851 .................... {
3852 .................... return ((exp(x)+exp(-x))/2); 3852 .................... return ((exp(x)+exp(-x))/2);
3853 .................... } 3853 .................... }
3854 .................... #endif 3854 .................... #endif
3855 .................... 3855 ....................
3856 .................... //////////////////////////////////////////////////////////////////////////// 3856 .................... ////////////////////////////////////////////////////////////////////////////
3857 .................... // float sinh(float x) 3857 .................... // float sinh(float x)
3858 .................... //////////////////////////////////////////////////////////////////////////// 3858 .................... ////////////////////////////////////////////////////////////////////////////
3859 .................... // Description : Computes the hyperbolic sine value of x 3859 .................... // Description : Computes the hyperbolic sine value of x
3860 .................... // Returns : returns the hyperbolic sine value of x 3860 .................... // Returns : returns the hyperbolic sine value of x
3861 .................... // Date : N/A 3861 .................... // Date : N/A
3862 .................... // 3862 .................... //
3863 .................... 3863 ....................
3864 .................... float32 sinh(float32 x) 3864 .................... float32 sinh(float32 x)
3865 .................... { 3865 .................... {
3866 .................... 3866 ....................
3867 .................... return ((exp(x) - exp(-x))/2); 3867 .................... return ((exp(x) - exp(-x))/2);
3868 .................... } 3868 .................... }
3869 .................... //Overloaded functions for sinh() for PCD 3869 .................... //Overloaded functions for sinh() for PCD
3870 .................... // Overloaded function sinh() for data type - Float48 3870 .................... // Overloaded function sinh() for data type - Float48
3871 .................... #if defined(__PCD__) 3871 .................... #if defined(__PCD__)
3872 .................... float48 sinh(float48 x) 3872 .................... float48 sinh(float48 x)
3873 .................... { 3873 .................... {
3874 .................... 3874 ....................
3875 .................... return ((exp(x) - exp(-x))/2); 3875 .................... return ((exp(x) - exp(-x))/2);
3876 .................... } 3876 .................... }
3877 .................... 3877 ....................
3878 .................... // Overloaded function sinh() for data type - Float48 3878 .................... // Overloaded function sinh() for data type - Float48
3879 .................... float64 sinh(float64 x) 3879 .................... float64 sinh(float64 x)
3880 .................... { 3880 .................... {
3881 .................... 3881 ....................
3882 .................... return ((exp(x) - exp(-x))/2); 3882 .................... return ((exp(x) - exp(-x))/2);
3883 .................... } 3883 .................... }
3884 .................... #endif 3884 .................... #endif
3885 .................... 3885 ....................
3886 .................... //////////////////////////////////////////////////////////////////////////// 3886 .................... ////////////////////////////////////////////////////////////////////////////
3887 .................... // float tanh(float x) 3887 .................... // float tanh(float x)
3888 .................... //////////////////////////////////////////////////////////////////////////// 3888 .................... ////////////////////////////////////////////////////////////////////////////
3889 .................... // Description : Computes the hyperbolic tangent value of x 3889 .................... // Description : Computes the hyperbolic tangent value of x
3890 .................... // Returns : returns the hyperbolic tangent value of x 3890 .................... // Returns : returns the hyperbolic tangent value of x
3891 .................... // Date : N/A 3891 .................... // Date : N/A
3892 .................... // 3892 .................... //
3893 .................... 3893 ....................
3894 .................... float32 tanh(float32 x) 3894 .................... float32 tanh(float32 x)
3895 .................... { 3895 .................... {
3896 .................... return(sinh(x)/cosh(x)); 3896 .................... return(sinh(x)/cosh(x));
3897 .................... } 3897 .................... }
3898 .................... //Overloaded functions for tanh() for PCD 3898 .................... //Overloaded functions for tanh() for PCD
3899 .................... // Overloaded function tanh() for data type - Float48 3899 .................... // Overloaded function tanh() for data type - Float48
3900 .................... #if defined(__PCD__) 3900 .................... #if defined(__PCD__)
3901 .................... float48 tanh(float48 x) 3901 .................... float48 tanh(float48 x)
3902 .................... { 3902 .................... {
3903 .................... return(sinh(x)/cosh(x)); 3903 .................... return(sinh(x)/cosh(x));
3904 .................... } 3904 .................... }
3905 .................... 3905 ....................
3906 .................... // Overloaded function tanh() for data type - Float64 3906 .................... // Overloaded function tanh() for data type - Float64
3907 .................... float64 tanh(float64 x) 3907 .................... float64 tanh(float64 x)
3908 .................... { 3908 .................... {
3909 .................... return(sinh(x)/cosh(x)); 3909 .................... return(sinh(x)/cosh(x));
3910 .................... } 3910 .................... }
3911 .................... #endif 3911 .................... #endif
3912 .................... 3912 ....................
3913 .................... //////////////////////////////////////////////////////////////////////////// 3913 .................... ////////////////////////////////////////////////////////////////////////////
3914 .................... // float frexp(float x, signed int *exp) 3914 .................... // float frexp(float x, signed int *exp)
3915 .................... //////////////////////////////////////////////////////////////////////////// 3915 .................... ////////////////////////////////////////////////////////////////////////////
3916 .................... // Description : breaks a floating point number into a normalized fraction and an integral 3916 .................... // Description : breaks a floating point number into a normalized fraction and an integral
3917 .................... // power of 2. It stores the integer in the signed int object pointed to by exp. 3917 .................... // power of 2. It stores the integer in the signed int object pointed to by exp.
3918 .................... // Returns : returns the value x, such that x is a double with magnitude in the interval 3918 .................... // Returns : returns the value x, such that x is a double with magnitude in the interval
3919 .................... // [1/2,1) or zero, and value equals x times 2 raised to the power *exp.If value is zero, 3919 .................... // [1/2,1) or zero, and value equals x times 2 raised to the power *exp.If value is zero,
3920 .................... // both parts of the result are zero. 3920 .................... // both parts of the result are zero.
3921 .................... // Date : N/A 3921 .................... // Date : N/A
3922 .................... // 3922 .................... //
3923 .................... 3923 ....................
3924 .................... #define LOG2 .30102999566398119521 3924 .................... #define LOG2 .30102999566398119521
3925 .................... float32 frexp(float32 x, signed int8 *exp) 3925 .................... float32 frexp(float32 x, signed int8 *exp)
3926 .................... { 3926 .................... {
3927 .................... float32 res; 3927 .................... float32 res;
3928 .................... int1 sign = 0; 3928 .................... int1 sign = 0;
3929 .................... if(x == 0.0) 3929 .................... if(x == 0.0)
3930 .................... { 3930 .................... {
3931 .................... *exp=0; 3931 .................... *exp=0;
3932 .................... return (0.0); 3932 .................... return (0.0);
3933 .................... } 3933 .................... }
3934 .................... if(x < 0.0) 3934 .................... if(x < 0.0)
3935 .................... { 3935 .................... {
3936 .................... x=-x; 3936 .................... x=-x;
3937 .................... sign=1; 3937 .................... sign=1;
3938 .................... } 3938 .................... }
3939 .................... if (x > 1.0) 3939 .................... if (x > 1.0)
3940 .................... { 3940 .................... {
3941 .................... *exp=(ceil(log10(x)/LOG2)); 3941 .................... *exp=(ceil(log10(x)/LOG2));
3942 .................... res=x/(pow(2, *exp)); 3942 .................... res=x/(pow(2, *exp));
3943 .................... if (res == 1) 3943 .................... if (res == 1)
3944 .................... { 3944 .................... {
3945 .................... *exp=*exp+1; 3945 .................... *exp=*exp+1;
3946 .................... res=.5; 3946 .................... res=.5;
3947 .................... } 3947 .................... }
3948 .................... } 3948 .................... }
3949 .................... else 3949 .................... else
3950 .................... { 3950 .................... {
3951 .................... if(x < 0.5) 3951 .................... if(x < 0.5)
3952 .................... { 3952 .................... {
3953 .................... *exp=-1; 3953 .................... *exp=-1;
3954 .................... res=x*2; 3954 .................... res=x*2;
3955 .................... } 3955 .................... }
3956 .................... else 3956 .................... else
3957 .................... { 3957 .................... {
3958 .................... *exp=0; 3958 .................... *exp=0;
3959 .................... res=x; 3959 .................... res=x;
3960 .................... } 3960 .................... }
3961 .................... } 3961 .................... }
3962 .................... if(sign) 3962 .................... if(sign)
3963 .................... { 3963 .................... {
3964 .................... res=-res; 3964 .................... res=-res;
3965 .................... } 3965 .................... }
3966 .................... return res; 3966 .................... return res;
3967 .................... } 3967 .................... }
3968 .................... 3968 ....................
3969 .................... //Overloaded functions for frexp() for PCD 3969 .................... //Overloaded functions for frexp() for PCD
3970 .................... // Overloaded function frexp() for data type - Float48 3970 .................... // Overloaded function frexp() for data type - Float48
3971 .................... #if defined(__PCD__) 3971 .................... #if defined(__PCD__)
3972 .................... float48 frexp(float48 x, signed int8 *exp) 3972 .................... float48 frexp(float48 x, signed int8 *exp)
3973 .................... { 3973 .................... {
3974 .................... float48 res; 3974 .................... float48 res;
3975 .................... int1 sign = 0; 3975 .................... int1 sign = 0;
3976 .................... if(x == 0.0) 3976 .................... if(x == 0.0)
3977 .................... { 3977 .................... {
3978 .................... *exp=0; 3978 .................... *exp=0;
3979 .................... return (0.0); 3979 .................... return (0.0);
3980 .................... } 3980 .................... }
3981 .................... if(x < 0.0) 3981 .................... if(x < 0.0)
3982 .................... { 3982 .................... {
3983 .................... x=-x; 3983 .................... x=-x;
3984 .................... sign=1; 3984 .................... sign=1;
3985 .................... } 3985 .................... }
3986 .................... if (x > 1.0) 3986 .................... if (x > 1.0)
3987 .................... { 3987 .................... {
3988 .................... *exp=(ceil(log10(x)/LOG2)); 3988 .................... *exp=(ceil(log10(x)/LOG2));
3989 .................... res=x/(pow(2, *exp)); 3989 .................... res=x/(pow(2, *exp));
3990 .................... if (res == 1) 3990 .................... if (res == 1)
3991 .................... { 3991 .................... {
3992 .................... *exp=*exp+1; 3992 .................... *exp=*exp+1;
3993 .................... res=.5; 3993 .................... res=.5;
3994 .................... } 3994 .................... }
3995 .................... } 3995 .................... }
3996 .................... else 3996 .................... else
3997 .................... { 3997 .................... {
3998 .................... if(x < 0.5) 3998 .................... if(x < 0.5)
3999 .................... { 3999 .................... {
4000 .................... *exp=-1; 4000 .................... *exp=-1;
4001 .................... res=x*2; 4001 .................... res=x*2;
4002 .................... } 4002 .................... }
4003 .................... else 4003 .................... else
4004 .................... { 4004 .................... {
4005 .................... *exp=0; 4005 .................... *exp=0;
4006 .................... res=x; 4006 .................... res=x;
4007 .................... } 4007 .................... }
4008 .................... } 4008 .................... }
4009 .................... if(sign) 4009 .................... if(sign)
4010 .................... { 4010 .................... {
4011 .................... res=-res; 4011 .................... res=-res;
4012 .................... } 4012 .................... }
4013 .................... return res; 4013 .................... return res;
4014 .................... } 4014 .................... }
4015 .................... 4015 ....................
4016 .................... // Overloaded function frexp() for data type - Float64 4016 .................... // Overloaded function frexp() for data type - Float64
4017 .................... float64 frexp(float64 x, signed int8 *exp) 4017 .................... float64 frexp(float64 x, signed int8 *exp)
4018 .................... { 4018 .................... {
4019 .................... float64 res; 4019 .................... float64 res;
4020 .................... int1 sign = 0; 4020 .................... int1 sign = 0;
4021 .................... if(x == 0.0) 4021 .................... if(x == 0.0)
4022 .................... { 4022 .................... {
4023 .................... *exp=0; 4023 .................... *exp=0;
4024 .................... return (0.0); 4024 .................... return (0.0);
4025 .................... } 4025 .................... }
4026 .................... if(x < 0.0) 4026 .................... if(x < 0.0)
4027 .................... { 4027 .................... {
4028 .................... x=-x; 4028 .................... x=-x;
4029 .................... sign=1; 4029 .................... sign=1;
4030 .................... } 4030 .................... }
4031 .................... if (x > 1.0) 4031 .................... if (x > 1.0)
4032 .................... { 4032 .................... {
4033 .................... *exp=(ceil(log10(x)/LOG2)); 4033 .................... *exp=(ceil(log10(x)/LOG2));
4034 .................... res=x/(pow(2, *exp)); 4034 .................... res=x/(pow(2, *exp));
4035 .................... if (res == 1) 4035 .................... if (res == 1)
4036 .................... { 4036 .................... {
4037 .................... *exp=*exp+1; 4037 .................... *exp=*exp+1;
4038 .................... res=.5; 4038 .................... res=.5;
4039 .................... } 4039 .................... }
4040 .................... } 4040 .................... }
4041 .................... else 4041 .................... else
4042 .................... { 4042 .................... {
4043 .................... if(x < 0.5) 4043 .................... if(x < 0.5)
4044 .................... { 4044 .................... {
4045 .................... *exp=-1; 4045 .................... *exp=-1;
4046 .................... res=x*2; 4046 .................... res=x*2;
4047 .................... } 4047 .................... }
4048 .................... else 4048 .................... else
4049 .................... { 4049 .................... {
4050 .................... *exp=0; 4050 .................... *exp=0;
4051 .................... res=x; 4051 .................... res=x;
4052 .................... } 4052 .................... }
4053 .................... } 4053 .................... }
4054 .................... if(sign) 4054 .................... if(sign)
4055 .................... { 4055 .................... {
4056 .................... res=-res; 4056 .................... res=-res;
4057 .................... } 4057 .................... }
4058 .................... return res; 4058 .................... return res;
4059 .................... } 4059 .................... }
4060 .................... #endif 4060 .................... #endif
4061 .................... 4061 ....................
4062 .................... ////////////////////////////////////////////////////////////////////////////// 4062 .................... //////////////////////////////////////////////////////////////////////////////
4063 .................... // float ldexp(float x, signed int *exp) 4063 .................... // float ldexp(float x, signed int *exp)
4064 .................... ////////////////////////////////////////////////////////////////////////////// 4064 .................... //////////////////////////////////////////////////////////////////////////////
4065 .................... // Description : multiplies a floating point number by an integral power of 2. 4065 .................... // Description : multiplies a floating point number by an integral power of 2.
4066 .................... // Returns : returns the value of x times 2 raised to the power exp. 4066 .................... // Returns : returns the value of x times 2 raised to the power exp.
4067 .................... // Date : N/A 4067 .................... // Date : N/A
4068 .................... // 4068 .................... //
4069 .................... 4069 ....................
4070 .................... float32 ldexp(float32 value, signed int8 exp) 4070 .................... float32 ldexp(float32 value, signed int8 exp)
4071 .................... { 4071 .................... {
4072 .................... return (value * pow(2,exp)); 4072 .................... return (value * pow(2,exp));
4073 .................... } 4073 .................... }
4074 .................... //Overloaded functions for ldexp() for PCD 4074 .................... //Overloaded functions for ldexp() for PCD
4075 .................... // Overloaded function ldexp() for data type - Float48 4075 .................... // Overloaded function ldexp() for data type - Float48
4076 .................... 4076 ....................
4077 .................... #if defined(__PCD__) 4077 .................... #if defined(__PCD__)
4078 .................... float48 ldexp(float48 value, signed int8 exp) 4078 .................... float48 ldexp(float48 value, signed int8 exp)
4079 .................... { 4079 .................... {
4080 .................... return (value * pow(2,exp)); 4080 .................... return (value * pow(2,exp));
4081 .................... } 4081 .................... }
4082 .................... // Overloaded function ldexp() for data type - Float64 4082 .................... // Overloaded function ldexp() for data type - Float64
4083 .................... float64 ldexp(float64 value, signed int8 exp) 4083 .................... float64 ldexp(float64 value, signed int8 exp)
4084 .................... { 4084 .................... {
4085 .................... return (value * pow(2,exp)); 4085 .................... return (value * pow(2,exp));
4086 .................... } 4086 .................... }
4087 .................... #endif 4087 .................... #endif
4088 .................... 4088 ....................
4089 .................... #endif 4089 .................... #endif
4090 .................... 4090 ....................
4091 .................... 4091 ....................
-   4092 .................... #define MPL3115_ADDR_R 0xC1 //addresa pro cteni
-   4093 .................... #define MPL3115_ADDR_W 0xC0
-   4094 ....................
-   4095 .................... #include "../MPL3115.h"
-   4096 .................... //microchip pic library for Freescale MPL3115 I2C barometer sensor
-   4097 ....................
-   4098 .................... /*void mpl3115_setA (void) //setup sensor for altitude measurement
-   4099 .................... void mpl3115_setP (void) //setup sensor for preasure measurement
-   4100 .................... float mpl3115_T (void) //temperature in Celsius degrees
-   4101 .................... float mpl3115_A (void) //altitude in metres
-   4102 .................... float mpl3115_P (void) //preassure in pascals
-   4103 .................... */
-   4104 ....................
-   4105 .................... #include "MPL3115.c"
-   4106 .................... void mpl3115_setA (void) //setup for altitude measurement
-   4107 .................... {
-   4108 ....................
-   4109 ....................
-   4110 .................... i2c_start(); //STANDBY mode
-   4111 .................... I2C_Write(MPL3115_ADDR_W);
-   4112 .................... I2C_write(0x26);
-   4113 .................... I2C_write(0xB8);
-   4114 .................... i2c_stop();
-   4115 ....................
-   4116 .................... i2c_start(); //PT_DATA_CFG set
-   4117 .................... I2C_Write(MPL3115_ADDR_W);
-   4118 .................... I2C_write(0x13);
-   4119 .................... I2C_write(0x07); //hodnota
-   4120 .................... i2c_stop();
-   4121 ....................
-   4122 .................... i2c_start(); //ACTIVE mode
-   4123 .................... I2C_Write(MPL3115_ADDR_W);
-   4124 .................... I2C_write(0x26);
-   4125 .................... I2C_write(0xB9);
-   4126 .................... i2c_stop();
-   4127 .................... }
-   4128 ....................
-   4129 .................... void mpl3115_setP (void) //nastavení pro tlak
-   4130 .................... {
-   4131 ....................
-   4132 ....................
-   4133 .................... i2c_start(); //STANDBY mode
-   4134 *
-   4135 09AD: BSF 20.4
-   4136 09AE: MOVF 20,W
-   4137 09AF: BSF 03.5
-   4138 09B0: MOVWF 07
-   4139 09B1: NOP
-   4140 09B2: BCF 03.5
-   4141 09B3: BSF 20.3
-   4142 09B4: MOVF 20,W
-   4143 09B5: BSF 03.5
-   4144 09B6: MOVWF 07
-   4145 09B7: NOP
-   4146 09B8: BCF 03.5
-   4147 09B9: BCF 07.4
-   4148 09BA: BCF 20.4
-   4149 09BB: MOVF 20,W
-   4150 09BC: BSF 03.5
-   4151 09BD: MOVWF 07
-   4152 09BE: NOP
-   4153 09BF: BCF 03.5
-   4154 09C0: BCF 07.3
-   4155 09C1: BCF 20.3
-   4156 09C2: MOVF 20,W
-   4157 09C3: BSF 03.5
-   4158 09C4: MOVWF 07
-   4159 .................... I2C_Write(MPL3115_ADDR_W);
-   4160 09C5: MOVLW C0
-   4161 09C6: BCF 03.5
-   4162 09C7: MOVWF 4E
-   4163 09C8: BCF 0A.3
-   4164 09C9: CALL 078
-   4165 09CA: BSF 0A.3
-   4166 .................... I2C_write(0x26);
-   4167 09CB: MOVLW 26
-   4168 09CC: MOVWF 4E
-   4169 09CD: BCF 0A.3
-   4170 09CE: CALL 078
-   4171 09CF: BSF 0A.3
-   4172 .................... I2C_write(0xB8);
-   4173 09D0: MOVLW B8
-   4174 09D1: MOVWF 4E
-   4175 09D2: BCF 0A.3
-   4176 09D3: CALL 078
-   4177 09D4: BSF 0A.3
-   4178 .................... i2c_stop();
-   4179 09D5: BCF 20.4
-   4180 09D6: MOVF 20,W
-   4181 09D7: BSF 03.5
-   4182 09D8: MOVWF 07
-   4183 09D9: NOP
-   4184 09DA: BCF 03.5
-   4185 09DB: BSF 20.3
-   4186 09DC: MOVF 20,W
-   4187 09DD: BSF 03.5
-   4188 09DE: MOVWF 07
-   4189 09DF: BCF 03.5
-   4190 09E0: BTFSS 07.3
-   4191 09E1: GOTO 1E0
-   4192 09E2: NOP
-   4193 09E3: GOTO 1E4
-   4194 09E4: NOP
-   4195 09E5: BSF 20.4
-   4196 09E6: MOVF 20,W
-   4197 09E7: BSF 03.5
-   4198 09E8: MOVWF 07
-   4199 09E9: NOP
-   4200 ....................
-   4201 .................... i2c_start(); //PT_DATA_CFG set
-   4202 09EA: BCF 03.5
-   4203 09EB: BSF 20.4
-   4204 09EC: MOVF 20,W
-   4205 09ED: BSF 03.5
-   4206 09EE: MOVWF 07
-   4207 09EF: NOP
-   4208 09F0: BCF 03.5
-   4209 09F1: BSF 20.3
-   4210 09F2: MOVF 20,W
-   4211 09F3: BSF 03.5
-   4212 09F4: MOVWF 07
-   4213 09F5: NOP
-   4214 09F6: BCF 03.5
-   4215 09F7: BCF 07.4
-   4216 09F8: BCF 20.4
-   4217 09F9: MOVF 20,W
-   4218 09FA: BSF 03.5
-   4219 09FB: MOVWF 07
-   4220 09FC: NOP
-   4221 09FD: BCF 03.5
-   4222 09FE: BCF 07.3
-   4223 09FF: BCF 20.3
-   4224 0A00: MOVF 20,W
-   4225 0A01: BSF 03.5
-   4226 0A02: MOVWF 07
-   4227 .................... I2C_Write(MPL3115_ADDR_W);
-   4228 0A03: MOVLW C0
-   4229 0A04: BCF 03.5
-   4230 0A05: MOVWF 4E
-   4231 0A06: BCF 0A.3
-   4232 0A07: CALL 078
-   4233 0A08: BSF 0A.3
-   4234 .................... I2C_write(0x13);
-   4235 0A09: MOVLW 13
-   4236 0A0A: MOVWF 4E
-   4237 0A0B: BCF 0A.3
-   4238 0A0C: CALL 078
-   4239 0A0D: BSF 0A.3
-   4240 .................... I2C_write(0x07); //hodnota
-   4241 0A0E: MOVLW 07
-   4242 0A0F: MOVWF 4E
-   4243 0A10: BCF 0A.3
-   4244 0A11: CALL 078
-   4245 0A12: BSF 0A.3
-   4246 .................... i2c_stop();
-   4247 0A13: BCF 20.4
-   4248 0A14: MOVF 20,W
-   4249 0A15: BSF 03.5
-   4250 0A16: MOVWF 07
-   4251 0A17: NOP
-   4252 0A18: BCF 03.5
-   4253 0A19: BSF 20.3
-   4254 0A1A: MOVF 20,W
-   4255 0A1B: BSF 03.5
-   4256 0A1C: MOVWF 07
-   4257 0A1D: BCF 03.5
-   4258 0A1E: BTFSS 07.3
-   4259 0A1F: GOTO 21E
-   4260 0A20: NOP
-   4261 0A21: GOTO 222
-   4262 0A22: NOP
-   4263 0A23: BSF 20.4
-   4264 0A24: MOVF 20,W
-   4265 0A25: BSF 03.5
-   4266 0A26: MOVWF 07
-   4267 0A27: NOP
-   4268 ....................
-   4269 .................... i2c_start(); //ACTIVE mode
-   4270 0A28: BCF 03.5
-   4271 0A29: BSF 20.4
-   4272 0A2A: MOVF 20,W
-   4273 0A2B: BSF 03.5
-   4274 0A2C: MOVWF 07
-   4275 0A2D: NOP
-   4276 0A2E: BCF 03.5
-   4277 0A2F: BSF 20.3
-   4278 0A30: MOVF 20,W
-   4279 0A31: BSF 03.5
-   4280 0A32: MOVWF 07
-   4281 0A33: NOP
-   4282 0A34: BCF 03.5
-   4283 0A35: BCF 07.4
-   4284 0A36: BCF 20.4
-   4285 0A37: MOVF 20,W
-   4286 0A38: BSF 03.5
-   4287 0A39: MOVWF 07
-   4288 0A3A: NOP
-   4289 0A3B: BCF 03.5
-   4290 0A3C: BCF 07.3
-   4291 0A3D: BCF 20.3
-   4292 0A3E: MOVF 20,W
-   4293 0A3F: BSF 03.5
-   4294 0A40: MOVWF 07
-   4295 .................... I2C_Write(MPL3115_ADDR_W);
-   4296 0A41: MOVLW C0
-   4297 0A42: BCF 03.5
-   4298 0A43: MOVWF 4E
-   4299 0A44: BCF 0A.3
-   4300 0A45: CALL 078
-   4301 0A46: BSF 0A.3
-   4302 .................... I2C_write(0x26);
-   4303 0A47: MOVLW 26
-   4304 0A48: MOVWF 4E
-   4305 0A49: BCF 0A.3
-   4306 0A4A: CALL 078
-   4307 0A4B: BSF 0A.3
-   4308 .................... I2C_write(0x39);
-   4309 0A4C: MOVLW 39
-   4310 0A4D: MOVWF 4E
-   4311 0A4E: BCF 0A.3
-   4312 0A4F: CALL 078
-   4313 0A50: BSF 0A.3
-   4314 .................... i2c_stop();
-   4315 0A51: BCF 20.4
-   4316 0A52: MOVF 20,W
-   4317 0A53: BSF 03.5
-   4318 0A54: MOVWF 07
-   4319 0A55: NOP
-   4320 0A56: BCF 03.5
-   4321 0A57: BSF 20.3
-   4322 0A58: MOVF 20,W
-   4323 0A59: BSF 03.5
-   4324 0A5A: MOVWF 07
-   4325 0A5B: BCF 03.5
-   4326 0A5C: BTFSS 07.3
-   4327 0A5D: GOTO 25C
-   4328 0A5E: NOP
-   4329 0A5F: GOTO 260
-   4330 0A60: NOP
-   4331 0A61: BSF 20.4
-   4332 0A62: MOVF 20,W
-   4333 0A63: BSF 03.5
-   4334 0A64: MOVWF 07
-   4335 0A65: NOP
-   4336 .................... }
-   4337 0A66: BCF 03.5
-   4338 0A67: BSF 0A.3
-   4339 0A68: BCF 0A.4
-   4340 0A69: GOTO 5EC (RETURN)
-   4341 ....................
-   4342 ....................
-   4343 .................... byte mpl3115_read (byte reg)
-   4344 .................... {
-   4345 .................... byte i;
-   4346 ....................
-   4347 .................... i2c_start();
-   4348 *
-   4349 079C: BSF 20.4
-   4350 079D: MOVF 20,W
-   4351 079E: BSF 03.5
-   4352 079F: MOVWF 07
-   4353 07A0: NOP
-   4354 07A1: BCF 03.5
-   4355 07A2: BSF 20.3
-   4356 07A3: MOVF 20,W
-   4357 07A4: BSF 03.5
-   4358 07A5: MOVWF 07
-   4359 07A6: NOP
-   4360 07A7: BCF 03.5
-   4361 07A8: BCF 07.4
-   4362 07A9: BCF 20.4
-   4363 07AA: MOVF 20,W
-   4364 07AB: BSF 03.5
-   4365 07AC: MOVWF 07
-   4366 07AD: NOP
-   4367 07AE: BCF 03.5
-   4368 07AF: BCF 07.3
-   4369 07B0: BCF 20.3
-   4370 07B1: MOVF 20,W
-   4371 07B2: BSF 03.5
-   4372 07B3: MOVWF 07
-   4373 .................... I2C_Write(MPL3115_ADDR_W);
-   4374 07B4: MOVLW C0
-   4375 07B5: BCF 03.5
-   4376 07B6: MOVWF 4E
-   4377 07B7: CALL 078
-   4378 .................... I2C_write(reg);
-   4379 07B8: MOVF 4C,W
-   4380 07B9: MOVWF 4E
-   4381 07BA: CALL 078
-   4382 .................... i2c_start();
-   4383 07BB: BSF 20.4
-   4384 07BC: MOVF 20,W
-   4385 07BD: BSF 03.5
-   4386 07BE: MOVWF 07
-   4387 07BF: NOP
-   4388 07C0: BCF 03.5
-   4389 07C1: BSF 20.3
-   4390 07C2: MOVF 20,W
-   4391 07C3: BSF 03.5
-   4392 07C4: MOVWF 07
-   4393 07C5: NOP
-   4394 07C6: BCF 03.5
-   4395 07C7: BTFSS 07.3
-   4396 07C8: GOTO 7C7
-   4397 07C9: BCF 07.4
-   4398 07CA: BCF 20.4
-   4399 07CB: MOVF 20,W
-   4400 07CC: BSF 03.5
-   4401 07CD: MOVWF 07
-   4402 07CE: NOP
-   4403 07CF: BCF 03.5
-   4404 07D0: BCF 07.3
-   4405 07D1: BCF 20.3
-   4406 07D2: MOVF 20,W
-   4407 07D3: BSF 03.5
-   4408 07D4: MOVWF 07
-   4409 .................... I2C_Write(MPL3115_ADDR_R);
-   4410 07D5: MOVLW C1
-   4411 07D6: BCF 03.5
-   4412 07D7: MOVWF 4E
-   4413 07D8: CALL 078
-   4414 .................... i=i2c_read(0);
-   4415 07D9: CLRF 77
-   4416 07DA: CALL 285
-   4417 07DB: MOVF 78,W
-   4418 07DC: MOVWF 4D
-   4419 .................... i2c_stop();
-   4420 07DD: BCF 20.4
-   4421 07DE: MOVF 20,W
-   4422 07DF: BSF 03.5
-   4423 07E0: MOVWF 07
-   4424 07E1: NOP
-   4425 07E2: BCF 03.5
-   4426 07E3: BSF 20.3
-   4427 07E4: MOVF 20,W
-   4428 07E5: BSF 03.5
-   4429 07E6: MOVWF 07
-   4430 07E7: BCF 03.5
-   4431 07E8: BTFSS 07.3
-   4432 07E9: GOTO 7E8
-   4433 07EA: NOP
-   4434 07EB: GOTO 7EC
-   4435 07EC: NOP
-   4436 07ED: BSF 20.4
-   4437 07EE: MOVF 20,W
-   4438 07EF: BSF 03.5
-   4439 07F0: MOVWF 07
-   4440 07F1: NOP
-   4441 ....................
-   4442 .................... return i;
-   4443 07F2: BCF 03.5
-   4444 07F3: MOVF 4D,W
-   4445 07F4: MOVWF 78
-   4446 .................... }
-   4447 07F5: RETURN
-   4448 ....................
-   4449 ....................
-   4450 .................... float mpl3115_T (void) //teplota ve stupnich
-   4451 .................... {
-   4452 .................... int m;
-   4453 .................... float l, t;
-   4454 ....................
-   4455 .................... m = mpl3115_read (0x04);
-   4456 *
-   4457 0891: MOVLW 04
-   4458 0892: MOVWF 4C
-   4459 0893: BCF 0A.3
-   4460 0894: CALL 79C
-   4461 0895: BSF 0A.3
-   4462 0896: MOVF 78,W
-   4463 0897: MOVWF 3D
-   4464 .................... l = (float)(mpl3115_read(0x05)>>4)/16.0;
-   4465 0898: MOVLW 05
-   4466 0899: MOVWF 4C
-   4467 089A: BCF 0A.3
-   4468 089B: CALL 79C
-   4469 089C: BSF 0A.3
-   4470 089D: SWAPF 78,W
-   4471 089E: MOVWF 77
-   4472 089F: MOVLW 0F
-   4473 08A0: ANDWF 77,F
-   4474 08A1: MOVF 77,W
-   4475 08A2: CLRF 4E
-   4476 08A3: MOVWF 4D
-   4477 08A4: BCF 0A.3
-   4478 08A5: CALL 2CA
-   4479 08A6: BSF 0A.3
-   4480 08A7: MOVF 77,W
-   4481 08A8: MOVWF 46
-   4482 08A9: MOVF 78,W
-   4483 08AA: MOVWF 47
-   4484 08AB: MOVF 79,W
-   4485 08AC: MOVWF 48
-   4486 08AD: MOVF 7A,W
-   4487 08AE: MOVWF 49
-   4488 08AF: MOVWF 54
-   4489 08B0: MOVF 48,W
-   4490 08B1: MOVWF 53
-   4491 08B2: MOVF 47,W
-   4492 08B3: MOVWF 52
-   4493 08B4: MOVF 46,W
-   4494 08B5: MOVWF 51
-   4495 08B6: CLRF 58
-   4496 08B7: CLRF 57
-   4497 08B8: CLRF 56
-   4498 08B9: MOVLW 83
-   4499 08BA: MOVWF 55
-   4500 08BB: BCF 0A.3
-   4501 08BC: CALL 2E7
-   4502 08BD: BSF 0A.3
-   4503 08BE: MOVF 7A,W
-   4504 08BF: MOVWF 41
-   4505 08C0: MOVF 79,W
-   4506 08C1: MOVWF 40
-   4507 08C2: MOVF 78,W
-   4508 08C3: MOVWF 3F
-   4509 08C4: MOVF 77,W
-   4510 08C5: MOVWF 3E
-   4511 .................... t = (float)(M + L);
-   4512 08C6: CLRF 4E
-   4513 08C7: MOVF 3D,W
-   4514 08C8: MOVWF 4D
-   4515 08C9: BCF 0A.3
-   4516 08CA: CALL 2CA
-   4517 08CB: BSF 0A.3
-   4518 08CC: BCF 03.1
-   4519 08CD: MOVF 7A,W
-   4520 08CE: MOVWF 56
-   4521 08CF: MOVF 79,W
-   4522 08D0: MOVWF 55
-   4523 08D1: MOVF 78,W
-   4524 08D2: MOVWF 54
-   4525 08D3: MOVF 77,W
-   4526 08D4: MOVWF 53
-   4527 08D5: MOVF 41,W
-   4528 08D6: MOVWF 5A
-   4529 08D7: MOVF 40,W
-   4530 08D8: MOVWF 59
-   4531 08D9: MOVF 3F,W
-   4532 08DA: MOVWF 58
-   4533 08DB: MOVF 3E,W
-   4534 08DC: MOVWF 57
-   4535 08DD: BCF 0A.3
-   4536 08DE: CALL 426
-   4537 08DF: BSF 0A.3
-   4538 08E0: MOVF 7A,W
-   4539 08E1: MOVWF 45
-   4540 08E2: MOVF 79,W
-   4541 08E3: MOVWF 44
-   4542 08E4: MOVF 78,W
-   4543 08E5: MOVWF 43
-   4544 08E6: MOVF 77,W
-   4545 08E7: MOVWF 42
-   4546 .................... return t;
-   4547 08E8: MOVF 42,W
-   4548 08E9: MOVWF 77
-   4549 08EA: MOVF 43,W
-   4550 08EB: MOVWF 78
-   4551 08EC: MOVF 44,W
-   4552 08ED: MOVWF 79
-   4553 08EE: MOVF 45,W
-   4554 08EF: MOVWF 7A
-   4555 .................... }
-   4556 08F0: BSF 0A.3
-   4557 08F1: BCF 0A.4
-   4558 08F2: GOTO 5DA (RETURN)
-   4559 ....................
-   4560 .................... float mpl3115_A (void) //vyska v m
-   4561 .................... {
-   4562 ....................
-   4563 .................... int16 m, c;
-   4564 .................... float l, a;
-   4565 ....................
-   4566 .................... m = mpl3115_read (0x01);
-   4567 .................... c = mpl3115_read (0x02);
-   4568 .................... l = (float)(mpl3115_read(0x03)>>4)/16.0;
-   4569 .................... a = (float)((m << 8)|c) + l;
-   4570 .................... return a;
-   4571 .................... }
-   4572 ....................
-   4573 ....................
-   4574 .................... float mpl3115_P (void) //tlak v Pa
-   4575 .................... {
-   4576 .................... unsigned int32 m;
-   4577 .................... unsigned int16 c;
-   4578 .................... unsigned int l;
-   4579 .................... float p, l1;
-   4580 ....................
-   4581 .................... m = mpl3115_read (0x01);
-   4582 08F3: MOVLW 01
-   4583 08F4: MOVWF 4C
-   4584 08F5: BCF 0A.3
-   4585 08F6: CALL 79C
-   4586 08F7: BSF 0A.3
-   4587 08F8: CLRF 40
-   4588 08F9: CLRF 3F
-   4589 08FA: CLRF 3E
-   4590 08FB: MOVF 78,W
-   4591 08FC: MOVWF 3D
-   4592 .................... c = mpl3115_read (0x02);
-   4593 08FD: MOVLW 02
-   4594 08FE: MOVWF 4C
-   4595 08FF: BCF 0A.3
-   4596 0900: CALL 79C
-   4597 0901: BSF 0A.3
-   4598 0902: CLRF 42
-   4599 0903: MOVF 78,W
-   4600 0904: MOVWF 41
-   4601 .................... l = mpl3115_read(0x03);
-   4602 0905: MOVLW 03
-   4603 0906: MOVWF 4C
-   4604 0907: BCF 0A.3
-   4605 0908: CALL 79C
-   4606 0909: BSF 0A.3
-   4607 090A: MOVF 78,W
-   4608 090B: MOVWF 43
-   4609 ....................
-   4610 .................... l1= (float)(l>>4)/4.0;
-   4611 090C: SWAPF 43,W
-   4612 090D: MOVWF 77
-   4613 090E: MOVLW 0F
-   4614 090F: ANDWF 77,F
-   4615 0910: MOVF 77,W
-   4616 0911: CLRF 4E
-   4617 0912: MOVWF 4D
-   4618 0913: BCF 0A.3
-   4619 0914: CALL 2CA
-   4620 0915: BSF 0A.3
-   4621 0916: MOVF 77,W
-   4622 0917: MOVWF 4D
-   4623 0918: MOVF 78,W
-   4624 0919: MOVWF 4E
-   4625 091A: MOVF 79,W
-   4626 091B: MOVWF 4F
-   4627 091C: MOVF 7A,W
-   4628 091D: MOVWF 50
-   4629 091E: MOVWF 54
-   4630 091F: MOVF 79,W
-   4631 0920: MOVWF 53
-   4632 0921: MOVF 78,W
-   4633 0922: MOVWF 52
-   4634 0923: MOVF 77,W
-   4635 0924: MOVWF 51
-   4636 0925: CLRF 58
-   4637 0926: CLRF 57
-   4638 0927: CLRF 56
-   4639 0928: MOVLW 81
-   4640 0929: MOVWF 55
-   4641 092A: BCF 0A.3
-   4642 092B: CALL 2E7
-   4643 092C: BSF 0A.3
-   4644 092D: MOVF 7A,W
-   4645 092E: MOVWF 4B
-   4646 092F: MOVF 79,W
-   4647 0930: MOVWF 4A
-   4648 0931: MOVF 78,W
-   4649 0932: MOVWF 49
-   4650 0933: MOVF 77,W
-   4651 0934: MOVWF 48
-   4652 .................... p = (float)((m << 10)|(c<<2)|(l>>6)) + l1;
-   4653 0935: CLRF 4D
-   4654 0936: RLF 3D,W
-   4655 0937: MOVWF 4E
-   4656 0938: RLF 3E,W
-   4657 0939: MOVWF 4F
-   4658 093A: RLF 3F,W
-   4659 093B: MOVWF 50
-   4660 093C: RLF 4E,F
-   4661 093D: RLF 4F,F
-   4662 093E: RLF 50,F
-   4663 093F: MOVLW FC
-   4664 0940: ANDWF 4E,F
-   4665 0941: RLF 41,W
-   4666 0942: MOVWF 79
-   4667 0943: RLF 42,W
-   4668 0944: MOVWF 7A
-   4669 0945: RLF 79,F
-   4670 0946: RLF 7A,F
-   4671 0947: MOVLW FC
-   4672 0948: ANDWF 79,F
-   4673 0949: MOVF 79,W
-   4674 094A: IORWF 4D,F
-   4675 094B: MOVF 7A,W
-   4676 094C: IORWF 4E,F
-   4677 094D: SWAPF 43,W
-   4678 094E: MOVWF 77
-   4679 094F: RRF 77,F
-   4680 0950: RRF 77,F
-   4681 0951: MOVLW 03
-   4682 0952: ANDWF 77,F
-   4683 0953: MOVF 77,W
-   4684 0954: IORWF 4D,W
-   4685 0955: MOVWF 77
-   4686 0956: MOVF 4E,W
-   4687 0957: MOVWF 78
-   4688 0958: MOVF 4F,W
-   4689 0959: MOVWF 79
-   4690 095A: MOVF 50,W
-   4691 095B: MOVWF 7A
-   4692 095C: MOVF 7A,W
-   4693 095D: MOVWF 56
-   4694 095E: MOVF 79,W
-   4695 095F: MOVWF 55
-   4696 0960: MOVF 78,W
-   4697 0961: MOVWF 54
-   4698 0962: MOVF 77,W
-   4699 0963: MOVWF 53
-   4700 *
-   4701 097E: MOVF 77,W
-   4702 097F: MOVWF 4D
-   4703 0980: MOVF 78,W
-   4704 0981: MOVWF 4E
-   4705 0982: MOVF 79,W
-   4706 0983: MOVWF 4F
-   4707 0984: MOVF 7A,W
-   4708 0985: MOVWF 50
-   4709 0986: BCF 03.1
-   4710 0987: MOVF 7A,W
-   4711 0988: MOVWF 56
-   4712 0989: MOVF 79,W
-   4713 098A: MOVWF 55
-   4714 098B: MOVF 78,W
-   4715 098C: MOVWF 54
-   4716 098D: MOVF 77,W
-   4717 098E: MOVWF 53
-   4718 098F: MOVF 4B,W
-   4719 0990: MOVWF 5A
-   4720 0991: MOVF 4A,W
-   4721 0992: MOVWF 59
-   4722 0993: MOVF 49,W
-   4723 0994: MOVWF 58
-   4724 0995: MOVF 48,W
-   4725 0996: MOVWF 57
-   4726 0997: BCF 0A.3
-   4727 0998: CALL 426
-   4728 0999: BSF 0A.3
-   4729 099A: MOVF 7A,W
-   4730 099B: MOVWF 47
-   4731 099C: MOVF 79,W
-   4732 099D: MOVWF 46
-   4733 099E: MOVF 78,W
-   4734 099F: MOVWF 45
-   4735 09A0: MOVF 77,W
-   4736 09A1: MOVWF 44
-   4737 ....................
-   4738 .................... return p;
-   4739 09A2: MOVF 44,W
-   4740 09A3: MOVWF 77
-   4741 09A4: MOVF 45,W
-   4742 09A5: MOVWF 78
-   4743 09A6: MOVF 46,W
-   4744 09A7: MOVWF 79
-   4745 09A8: MOVF 47,W
-   4746 09A9: MOVWF 7A
-   4747 .................... }
-   4748 09AA: BSF 0A.3
-   4749 09AB: BCF 0A.4
-   4750 09AC: GOTO 5E3 (RETURN)
-   4751 ....................
-   4752 ....................
-   4753 ....................
-   4754 ....................
-   4755 ....................
4092 .................... 4756 ....................
4093 .................... void main() 4757 .................... void main()
4094 .................... { 4758 .................... {
4095 * 4759 *
4096 0AB7: CLRF 04 4760 0CE5: CLRF 04
4097 0AB8: BCF 03.7 4761 0CE6: BCF 03.7
4098 0AB9: MOVLW 1F 4762 0CE7: MOVLW 1F
4099 0ABA: ANDWF 03,F 4763 0CE8: ANDWF 03,F
4100 0ABB: MOVLW 71 4764 0CE9: MOVLW 71
4101 0ABC: BSF 03.5 4765 0CEA: BSF 03.5
4102 0ABD: MOVWF 0F 4766 0CEB: MOVWF 0F
4103 0ABE: MOVF 0F,W 4767 0CEC: MOVF 0F,W
4104 0ABF: BSF 03.6 4768 0CED: BSF 03.6
4105 0AC0: BCF 07.3 4769 0CEE: BCF 07.3
4106 0AC1: MOVLW 0C 4770 0CEF: MOVLW 0C
4107 0AC2: BCF 03.6 4771 0CF0: BCF 03.6
4108 0AC3: MOVWF 19 4772 0CF1: MOVWF 19
4109 0AC4: MOVLW A2 4773 0CF2: MOVLW A2
4110 0AC5: MOVWF 18 4774 0CF3: MOVWF 18
4111 0AC6: MOVLW 90 4775 0CF4: MOVLW 90
4112 0AC7: BCF 03.5 4776 0CF5: BCF 03.5
4113 0AC8: MOVWF 18 4777 0CF6: MOVWF 18
4114 0AC9: BSF 03.5 4778 0CF7: BSF 03.5
4115 0ACA: BSF 03.6 4779 0CF8: BSF 03.6
4116 0ACB: MOVF 09,W 4780 0CF9: MOVF 09,W
4117 0ACC: ANDLW C0 4781 0CFA: ANDLW C0
4118 0ACD: MOVWF 09 4782 0CFB: MOVWF 09
4119 0ACE: BCF 03.6 4783 0CFC: BCF 03.6
4120 0ACF: BCF 1F.4 4784 0CFD: BCF 1F.4
4121 0AD0: BCF 1F.5 4785 0CFE: BCF 1F.5
4122 0AD1: MOVLW 00 4786 0CFF: MOVLW 00
4123 0AD2: BSF 03.6 4787 0D00: BSF 03.6
4124 0AD3: MOVWF 08 4788 0D01: MOVWF 08
4125 0AD4: BCF 03.5 4789 0D02: BCF 03.5
4126 0AD5: CLRF 07 4790 0D03: CLRF 07
4127 0AD6: CLRF 08 4791 0D04: CLRF 08
4128 0AD7: CLRF 09 4792 0D05: CLRF 09
4129 * 4793 *
4130 0AE1: CLRF 34 4794 0D0F: CLRF 3C
4131 0AE2: CLRF 33 4795 0D10: CLRF 3B
4132 .................... float temp1, temp2, humidity; 4796 .................... float temp1, temp2, temp3, humidity, preasure;
4133 .................... int16 i=0; 4797 .................... int16 i=0;
4134 .................... 4798 ....................
4135 .................... setup_adc_ports(NO_ANALOGS|VSS_VDD); 4799 .................... setup_adc_ports(NO_ANALOGS|VSS_VDD);
4136 0AE3: BSF 03.5 4800 0D11: BSF 03.5
4137 0AE4: BSF 03.6 4801 0D12: BSF 03.6
4138 0AE5: MOVF 09,W 4802 0D13: MOVF 09,W
4139 0AE6: ANDLW C0 4803 0D14: ANDLW C0
4140 0AE7: MOVWF 09 4804 0D15: MOVWF 09
4141 0AE8: BCF 03.6 4805 0D16: BCF 03.6
4142 0AE9: BCF 1F.4 4806 0D17: BCF 1F.4
4143 0AEA: BCF 1F.5 4807 0D18: BCF 1F.5
4144 0AEB: MOVLW 00 4808 0D19: MOVLW 00
4145 0AEC: BSF 03.6 4809 0D1A: BSF 03.6
4146 0AED: MOVWF 08 4810 0D1B: MOVWF 08
4147 .................... setup_adc(ADC_CLOCK_DIV_2); 4811 .................... setup_adc(ADC_CLOCK_DIV_2);
4148 0AEE: BCF 03.5 4812 0D1C: BCF 03.5
4149 0AEF: BCF 03.6 4813 0D1D: BCF 03.6
4150 0AF0: BCF 1F.6 4814 0D1E: BCF 1F.6
4151 0AF1: BCF 1F.7 4815 0D1F: BCF 1F.7
4152 0AF2: BSF 03.5 4816 0D20: BSF 03.5
4153 0AF3: BSF 1F.7 4817 0D21: BSF 1F.7
4154 0AF4: BCF 03.5 4818 0D22: BCF 03.5
4155 0AF5: BSF 1F.0 4819 0D23: BSF 1F.0
4156 .................... setup_spi(SPI_SS_DISABLED); 4820 .................... setup_spi(SPI_SS_DISABLED);
4157 0AF6: BCF 14.5 4821 0D24: BCF 14.5
4158 0AF7: BCF 20.5 4822 0D25: BCF 20.5
4159 0AF8: MOVF 20,W 4823 0D26: MOVF 20,W
4160 0AF9: BSF 03.5 4824 0D27: BSF 03.5
4161 0AFA: MOVWF 07 4825 0D28: MOVWF 07
4162 0AFB: BCF 03.5 4826 0D29: BCF 03.5
4163 0AFC: BSF 20.4 4827 0D2A: BSF 20.4
4164 0AFD: MOVF 20,W 4828 0D2B: MOVF 20,W
4165 0AFE: BSF 03.5 4829 0D2C: BSF 03.5
4166 0AFF: MOVWF 07 4830 0D2D: MOVWF 07
4167 0B00: BCF 03.5 4831 0D2E: BCF 03.5
4168 0B01: BCF 20.3 4832 0D2F: BCF 20.3
4169 0B02: MOVF 20,W 4833 0D30: MOVF 20,W
4170 0B03: BSF 03.5 4834 0D31: BSF 03.5
4171 0B04: MOVWF 07 4835 0D32: MOVWF 07
4172 0B05: MOVLW 01 4836 0D33: MOVLW 01
4173 0B06: BCF 03.5 4837 0D34: BCF 03.5
4174 0B07: MOVWF 14 4838 0D35: MOVWF 14
4175 0B08: MOVLW 00 4839 0D36: MOVLW 00
4176 0B09: BSF 03.5 4840 0D37: BSF 03.5
4177 0B0A: MOVWF 14 4841 0D38: MOVWF 14
4178 .................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); 4842 .................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
4179 0B0B: MOVF 01,W 4843 0D39: MOVF 01,W
4180 0B0C: ANDLW C7 4844 0D3A: ANDLW C7
4181 0B0D: IORLW 08 4845 0D3B: IORLW 08
4182 0B0E: MOVWF 01 4846 0D3C: MOVWF 01
4183 .................... setup_timer_1(T1_DISABLED); 4847 .................... setup_timer_1(T1_DISABLED);
4184 0B0F: BCF 03.5 4848 0D3D: BCF 03.5
4185 0B10: CLRF 10 4849 0D3E: CLRF 10
4186 .................... setup_timer_2(T2_DISABLED,0,1); 4850 .................... setup_timer_2(T2_DISABLED,0,1);
4187 0B11: MOVLW 00 4851 0D3F: MOVLW 00
4188 0B12: MOVWF 78 4852 0D40: MOVWF 78
4189 0B13: MOVWF 12 4853 0D41: MOVWF 12
4190 0B14: MOVLW 00 4854 0D42: MOVLW 00
4191 0B15: BSF 03.5 4855 0D43: BSF 03.5
4192 0B16: MOVWF 12 4856 0D44: MOVWF 12
4193 .................... setup_ccp1(CCP_OFF); 4857 .................... setup_ccp1(CCP_OFF);
4194 0B17: BCF 03.5 4858 0D45: BCF 03.5
4195 0B18: BSF 20.2 4859 0D46: BSF 20.2
4196 0B19: MOVF 20,W 4860 0D47: MOVF 20,W
4197 0B1A: BSF 03.5 4861 0D48: BSF 03.5
4198 0B1B: MOVWF 07 4862 0D49: MOVWF 07
4199 0B1C: BCF 03.5 4863 0D4A: BCF 03.5
4200 0B1D: CLRF 17 4864 0D4B: CLRF 17
4201 0B1E: BSF 03.5 4865 0D4C: BSF 03.5
4202 0B1F: CLRF 1B 4866 0D4D: CLRF 1B
4203 0B20: CLRF 1C 4867 0D4E: CLRF 1C
4204 0B21: MOVLW 01 4868 0D4F: MOVLW 01
4205 0B22: MOVWF 1D 4869 0D50: MOVWF 1D
4206 .................... setup_comparator(NC_NC_NC_NC); // This device COMP currently not supported by the PICWizard 4870 .................... setup_comparator(NC_NC_NC_NC); // This device COMP currently not supported by the PICWizard
4207 0B23: BCF 03.5 4871 0D51: BCF 03.5
4208 0B24: BSF 03.6 4872 0D52: BSF 03.6
4209 0B25: CLRF 07 4873 0D53: CLRF 07
4210 0B26: CLRF 08 4874 0D54: CLRF 08
4211 0B27: CLRF 09 4875 0D55: CLRF 09
4212 .................... setup_oscillator(OSC_8MHZ); 4876 .................... setup_oscillator(OSC_8MHZ);
4213 0B28: MOVLW 71 4877 0D56: MOVLW 71
4214 0B29: BSF 03.5 4878 0D57: BSF 03.5
4215 0B2A: BCF 03.6 4879 0D58: BCF 03.6
4216 0B2B: MOVWF 0F 4880 0D59: MOVWF 0F
4217 0B2C: MOVF 0F,W 4881 0D5A: MOVF 0F,W
4218 .................... 4882 ....................
4219 .................... 4883 ....................
4220 .................... printf("GeoMet01A\r\n"); 4884 .................... printf("GeoMet01A\r\n");
4221 0B2D: MOVLW 0C 4885 0D5B: MOVLW 0C
4222 0B2E: BCF 03.5 4886 0D5C: BCF 03.5
4223 0B2F: BSF 03.6 4887 0D5D: BSF 03.6
4224 0B30: MOVWF 0D 4888 0D5E: MOVWF 0D
4225 0B31: MOVLW 00 4889 0D5F: MOVLW 00
4226 0B32: MOVWF 0F 4890 0D60: MOVWF 0F
4227 0B33: BCF 0A.3 4891 0D61: BCF 0A.3
4228 0B34: BCF 03.6 4892 0D62: BCF 03.6
4229 0B35: CALL 030 4893 0D63: CALL 030
4230 0B36: BSF 0A.3 4894 0D64: BSF 0A.3
4231 .................... printf("(c) Kaklik 2013\r\n"); 4895 .................... printf("(c) Kaklik 2013\r\n");
4232 0B37: MOVLW 12 4896 0D65: MOVLW 12
4233 0B38: BSF 03.6 4897 0D66: BSF 03.6
4234 0B39: MOVWF 0D 4898 0D67: MOVWF 0D
4235 0B3A: MOVLW 00 4899 0D68: MOVLW 00
4236 0B3B: MOVWF 0F 4900 0D69: MOVWF 0F
4237 0B3C: BCF 0A.3 4901 0D6A: BCF 0A.3
4238 0B3D: BCF 03.6 4902 0D6B: BCF 03.6
4239 0B3E: CALL 030 4903 0D6C: CALL 030
4240 0B3F: BSF 0A.3 4904 0D6D: BSF 0A.3
4241 .................... printf("www.mlab.cz\r\n"); 4905 .................... printf("www.mlab.cz\r\n");
4242 0B40: MOVLW 1B 4906 0D6E: MOVLW 1B
4243 0B41: BSF 03.6 4907 0D6F: BSF 03.6
4244 0B42: MOVWF 0D 4908 0D70: MOVWF 0D
4245 0B43: MOVLW 00 4909 0D71: MOVLW 00
4246 0B44: MOVWF 0F 4910 0D72: MOVWF 0F
4247 0B45: BCF 0A.3 4911 0D73: BCF 0A.3
4248 0B46: BCF 03.6 4912 0D74: BCF 03.6
4249 0B47: CALL 030 4913 0D75: CALL 030
4250 0B48: BSF 0A.3 4914 0D76: BSF 0A.3
4251 .................... 4915 ....................
4252 .................... // Init the HMC5883L. Set Mode register for 4916 .................... // Init the HMC5883L. Set Mode register for
4253 .................... // continuous measurements. 4917 .................... // continuous measurements.
4254 .................... hmc5883l_write_reg(HMC5883L_CFG_A_REG, 0x18); // no average, maximal update range 4918 .................... hmc5883l_write_reg(HMC5883L_CFG_A_REG, 0x18); // no average, maximal update range
4255 0B49: CLRF 35 4919 0D77: CLRF 3D
4256 0B4A: MOVLW 18 4920 0D78: MOVLW 18
4257 0B4B: MOVWF 36 4921 0D79: MOVWF 3E
4258 0B4C: BCF 0A.3 4922 0D7A: BCF 0A.3
4259 0B4D: CALL 0C2 4923 0D7B: CALL 0C2
4260 0B4E: BSF 0A.3 4924 0D7C: BSF 0A.3
4261 .................... hmc5883l_write_reg(HMC5883L_CFG_B_REG, 0x00); // minimal range 4925 .................... hmc5883l_write_reg(HMC5883L_CFG_B_REG, 0x00); // minimal range
4262 0B4F: MOVLW 01 4926 0D7D: MOVLW 01
4263 0B50: MOVWF 35 4927 0D7E: MOVWF 3D
4264 0B51: CLRF 36 4928 0D7F: CLRF 3E
4265 0B52: BCF 0A.3 4929 0D80: BCF 0A.3
4266 0B53: CALL 0C2 4930 0D81: CALL 0C2
4267 0B54: BSF 0A.3 4931 0D82: BSF 0A.3
4268 .................... hmc5883l_write_reg(HMC5883L_MODE_REG, 0x00); 4932 .................... hmc5883l_write_reg(HMC5883L_MODE_REG, 0x00);
4269 0B55: MOVLW 02 4933 0D83: MOVLW 02
4270 0B56: MOVWF 35 4934 0D84: MOVWF 3D
4271 0B57: CLRF 36 4935 0D85: CLRF 3E
4272 0B58: BCF 0A.3 4936 0D86: BCF 0A.3
4273 0B59: CALL 0C2 4937 0D87: CALL 0C2
4274 0B5A: BSF 0A.3 4938 0D88: BSF 0A.3
4275 .................... 4939 ....................
4276 .................... lcd_init(); 4940 .................... lcd_init();
4277 0B5B: BCF 0A.3 4941 0D89: BCF 0A.3
4278 0B5C: CALL 1C8 4942 0D8A: CALL 1C8
4279 0B5D: BSF 0A.3 4943 0D8B: BSF 0A.3
4280 .................... lcd_putc("(c) Kaklik 2013"); 4944 .................... lcd_putc("(c) Kaklik 2013");
4281 0B5E: MOVLW 22 4945 0D8C: MOVLW 22
4282 0B5F: BSF 03.6 4946 0D8D: BSF 03.6
4283 0B60: MOVWF 0D 4947 0D8E: MOVWF 0D
4284 0B61: MOVLW 00 4948 0D8F: MOVLW 00
4285 0B62: MOVWF 0F 4949 0D90: MOVWF 0F
4286 0B63: BCF 0A.3 4950 0D91: BCF 0A.3
4287 0B64: BCF 03.6 4951 0D92: BCF 03.6
4288 0B65: CALL 23F 4952 0D93: CALL 23F
4289 0B66: BSF 0A.3 4953 0D94: BSF 0A.3
4290 .................... lcd_gotoxy(3,2); 4954 .................... lcd_gotoxy(3,2);
4291 0B67: MOVLW 03 4955 0D95: MOVLW 03
4292 0B68: MOVWF 43 4956 0D96: MOVWF 4B
4293 0B69: MOVLW 02 4957 0D97: MOVLW 02
4294 0B6A: MOVWF 44 4958 0D98: MOVWF 4C
4295 0B6B: BCF 0A.3 4959 0D99: BCF 0A.3
4296 0B6C: CALL 200 4960 0D9A: CALL 200
4297 0B6D: BSF 0A.3 4961 0D9B: BSF 0A.3
4298 .................... lcd_putc("www.mlab.cz"); 4962 .................... lcd_putc("www.mlab.cz");
4299 0B6E: MOVLW 2A 4963 0D9C: MOVLW 2A
4300 0B6F: BSF 03.6 4964 0D9D: BSF 03.6
4301 0B70: MOVWF 0D 4965 0D9E: MOVWF 0D
4302 0B71: MOVLW 00 4966 0D9F: MOVLW 00
4303 0B72: MOVWF 0F 4967 0DA0: MOVWF 0F
4304 0B73: BCF 0A.3 4968 0DA1: BCF 0A.3
4305 0B74: BCF 03.6 4969 0DA2: BCF 03.6
4306 0B75: CALL 23F 4970 0DA3: CALL 23F
4307 0B76: BSF 0A.3 4971 0DA4: BSF 0A.3
4308 .................... Delay_ms(2000); 4972 .................... Delay_ms(2000);
4309 0B77: MOVLW 08 4973 0DA5: MOVLW 08
4310 0B78: MOVWF 35 4974 0DA6: MOVWF 3D
4311 0B79: MOVLW FA 4975 0DA7: MOVLW FA
4312 0B7A: MOVWF 43 4976 0DA8: MOVWF 4B
4313 0B7B: BCF 0A.3 4977 0DA9: BCF 0A.3
4314 0B7C: CALL 0FB 4978 0DAA: CALL 0FB
4315 0B7D: BSF 0A.3 4979 0DAB: BSF 0A.3
4316 0B7E: DECFSZ 35,F 4980 0DAC: DECFSZ 3D,F
4317 0B7F: GOTO 379 4981 0DAD: GOTO 5A7
4318 .................... lcd_init(); 4982 .................... lcd_init();
4319 0B80: BCF 0A.3 4983 0DAE: BCF 0A.3
4320 0B81: CALL 1C8 4984 0DAF: CALL 1C8
4321 0B82: BSF 0A.3 4985 0DB0: BSF 0A.3
4322 .................... 4986 ....................
4323 .................... while (TRUE) 4987 .................... while (TRUE)
4324 .................... { 4988 .................... {
4325 .................... lcd_gotoxy(1,1); 4989 .................... lcd_gotoxy(1,1);
4326 0B83: MOVLW 01 4990 0DB1: MOVLW 01
4327 0B84: MOVWF 43 4991 0DB2: MOVWF 4B
4328 0B85: MOVWF 44 4992 0DB3: MOVWF 4C
4329 0B86: BCF 0A.3 4993 0DB4: BCF 0A.3
4330 0B87: CALL 200 4994 0DB5: CALL 200
4331 0B88: BSF 0A.3 4995 0DB6: BSF 0A.3
4332 .................... temp1 = SHT25_get_temp(); 4996 .................... temp1 = SHT25_get_temp();
4333 0B89: BCF 0A.3 4997 0DB7: BCF 0A.3
4334 0B8A: GOTO 567 4998 0DB8: GOTO 567
4335 0B8B: BSF 0A.3 4999 0DB9: BSF 0A.3
4336 0B8C: MOVF 7A,W 5000 0DBA: MOVF 7A,W
4337 0B8D: MOVWF 2A 5001 0DBB: MOVWF 2A
4338 0B8E: MOVF 79,W 5002 0DBC: MOVF 79,W
4339 0B8F: MOVWF 29 5003 0DBD: MOVWF 29
4340 0B90: MOVF 78,W 5004 0DBE: MOVF 78,W
4341 0B91: MOVWF 28 5005 0DBF: MOVWF 28
4342 0B92: MOVF 77,W 5006 0DC0: MOVF 77,W
4343 0B93: MOVWF 27 5007 0DC1: MOVWF 27
4344 .................... humidity = SHT25_get_hum(); 5008 .................... humidity = SHT25_get_hum();
4345 0B94: BCF 0A.3 5009 0DC2: BCF 0A.3
4346 0B95: GOTO 636 5010 0DC3: GOTO 636
4347 0B96: BSF 0A.3 5011 0DC4: BSF 0A.3
4348 0B97: MOVF 7A,W 5012 0DC5: MOVF 7A,W
4349 0B98: MOVWF 32 5013 0DC6: MOVWF 36
4350 0B99: MOVF 79,W 5014 0DC7: MOVF 79,W
4351 0B9A: MOVWF 31 5015 0DC8: MOVWF 35
4352 0B9B: MOVF 78,W 5016 0DC9: MOVF 78,W
4353 0B9C: MOVWF 30 5017 0DCA: MOVWF 34
4354 0B9D: MOVF 77,W 5018 0DCB: MOVF 77,W
4355 0B9E: MOVWF 2F 5019 0DCC: MOVWF 33
4356 .................... temp2= LTS01_get_temp(); 5020 .................... temp2= LTS01_get_temp();
4357 0B9F: BCF 0A.3 5021 0DCD: BCF 0A.3
4358 0BA0: GOTO 6EC 5022 0DCE: GOTO 6EC
4359 0BA1: BSF 0A.3 5023 0DCF: BSF 0A.3
4360 0BA2: MOVF 7A,W 5024 0DD0: MOVF 7A,W
4361 0BA3: MOVWF 2E 5025 0DD1: MOVWF 2E
4362 0BA4: MOVF 79,W 5026 0DD2: MOVF 79,W
4363 0BA5: MOVWF 2D 5027 0DD3: MOVWF 2D
4364 0BA6: MOVF 78,W 5028 0DD4: MOVF 78,W
4365 0BA7: MOVWF 2C 5029 0DD5: MOVWF 2C
4366 0BA8: MOVF 77,W 5030 0DD6: MOVF 77,W
4367 0BA9: MOVWF 2B 5031 0DD7: MOVWF 2B
4368 .................... hmc5883l_read_data(); 5032 .................... hmc5883l_read_data();
4369 0BAA: GOTO 000 5033 0DD8: GOTO 000
4370 .................... 5034 ....................
4371 .................... printf(lcd_putc,"%f C %f \%%",temp1, humidity); 5035 .................... temp3=mpl3115_T();
-   5036 0DD9: GOTO 091
-   5037 0DDA: MOVF 7A,W
4372 0BAB: MOVLW 89 5038 0DDB: MOVWF 32
-   5039 0DDC: MOVF 79,W
-   5040 0DDD: MOVWF 31
-   5041 0DDE: MOVF 78,W
-   5042 0DDF: MOVWF 30
-   5043 0DE0: MOVF 77,W
4373 0BAC: MOVWF 04 5044 0DE1: MOVWF 2F
-   5045 .................... preasure=mpl3115_P();
-   5046 0DE2: GOTO 0F3
4374 0BAD: MOVF 2A,W 5047 0DE3: MOVF 7A,W
4375 0BAE: MOVWF 38 5048 0DE4: MOVWF 3A
4376 0BAF: MOVF 29,W 5049 0DE5: MOVF 79,W
4377 0BB0: MOVWF 37 5050 0DE6: MOVWF 39
4378 0BB1: MOVF 28,W 5051 0DE7: MOVF 78,W
4379 0BB2: MOVWF 36 5052 0DE8: MOVWF 38
4380 0BB3: MOVF 27,W 5053 0DE9: MOVF 77,W
4381 0BB4: MOVWF 35 5054 0DEA: MOVWF 37
-   5055 .................... mpl3115_setP(); //nastaveni pro tlak a teplotu
-   5056 0DEB: GOTO 1AD
-   5057 ....................
-   5058 .................... printf(lcd_putc,"%2.2f%cC %2.2f\%%",temp1, 0xb2, humidity);
4382 0BB5: MOVLW 02 5059 0DEC: MOVLW 89
4383 0BB6: MOVWF 39 5060 0DED: MOVWF 04
4384 0BB7: CALL 091 5061 0DEE: MOVF 2A,W
4385 0BB8: MOVLW 20 5062 0DEF: MOVWF 40
-   5063 0DF0: MOVF 29,W
-   5064 0DF1: MOVWF 3F
-   5065 0DF2: MOVF 28,W
4386 0BB9: MOVWF 42 5066 0DF3: MOVWF 3E
4387 0BBA: BCF 0A.3 5067 0DF4: MOVF 27,W
-   5068 0DF5: MOVWF 3D
4388 0BBB: CALL 212 5069 0DF6: MOVLW 02
-   5070 0DF7: MOVWF 41
4389 0BBC: BSF 0A.3 5071 0DF8: CALL 2CB
4390 0BBD: MOVLW 43 5072 0DF9: MOVLW B2
4391 0BBE: MOVWF 42 5073 0DFA: MOVWF 4A
4392 0BBF: BCF 0A.3 5074 0DFB: BCF 0A.3
4393 0BC0: CALL 212 5075 0DFC: CALL 212
4394 0BC1: BSF 0A.3 5076 0DFD: BSF 0A.3
4395 0BC2: MOVLW 20 5077 0DFE: MOVLW 43
4396 0BC3: MOVWF 42 5078 0DFF: MOVWF 4A
4397 0BC4: BCF 0A.3 5079 0E00: BCF 0A.3
4398 0BC5: CALL 212 5080 0E01: CALL 212
4399 0BC6: BSF 0A.3 5081 0E02: BSF 0A.3
4400 0BC7: MOVLW 89 5082 0E03: MOVLW 20
4401 0BC8: MOVWF 04 5083 0E04: MOVWF 4A
-   5084 0E05: BCF 0A.3
4402 0BC9: MOVF 32,W 5085 0E06: CALL 212
4403 0BCA: MOVWF 38 5086 0E07: BSF 0A.3
4404 0BCB: MOVF 31,W 5087 0E08: MOVLW 89
4405 0BCC: MOVWF 37 5088 0E09: MOVWF 04
4406 0BCD: MOVF 30,W 5089 0E0A: MOVF 36,W
4407 0BCE: MOVWF 36 5090 0E0B: MOVWF 40
4408 0BCF: MOVF 2F,W 5091 0E0C: MOVF 35,W
4409 0BD0: MOVWF 35 5092 0E0D: MOVWF 3F
4410 0BD1: MOVLW 02 5093 0E0E: MOVF 34,W
4411 0BD2: MOVWF 39 5094 0E0F: MOVWF 3E
4412 0BD3: CALL 091 5095 0E10: MOVF 33,W
4413 0BD4: MOVLW 20 5096 0E11: MOVWF 3D
4414 0BD5: MOVWF 42 5097 0E12: MOVLW 02
4415 0BD6: BCF 0A.3 5098 0E13: MOVWF 41
4416 0BD7: CALL 212 5099 0E14: CALL 2CB
4417 0BD8: BSF 0A.3 -  
4418 0BD9: MOVLW 25 5100 0E15: MOVLW 25
4419 0BDA: MOVWF 42 5101 0E16: MOVWF 4A
4420 0BDB: BCF 0A.3 5102 0E17: BCF 0A.3
4421 0BDC: CALL 212 5103 0E18: CALL 212
4422 0BDD: BSF 0A.3 5104 0E19: BSF 0A.3
4423 .................... lcd_gotoxy(1,2); 5105 .................... lcd_gotoxy(1,2);
4424 0BDE: MOVLW 01 5106 0E1A: MOVLW 01
4425 0BDF: MOVWF 43 5107 0E1B: MOVWF 4B
4426 0BE0: MOVLW 02 5108 0E1C: MOVLW 02
4427 0BE1: MOVWF 44 5109 0E1D: MOVWF 4C
4428 0BE2: BCF 0A.3 5110 0E1E: BCF 0A.3
4429 0BE3: CALL 200 5111 0E1F: CALL 200
4430 0BE4: BSF 0A.3 5112 0E20: BSF 0A.3
4431 .................... printf(lcd_putc," %f C",temp2); 5113 .................... printf(lcd_putc,"%2.2f%cC %6.0fPa ",temp2, 0xb2, preasure);
4432 0BE5: MOVLW 20 5114 0E21: MOVLW 89
4433 0BE6: MOVWF 42 5115 0E22: MOVWF 04
4434 0BE7: BCF 0A.3 5116 0E23: MOVF 2E,W
4435 0BE8: CALL 212 5117 0E24: MOVWF 40
4436 0BE9: BSF 0A.3 5118 0E25: MOVF 2D,W
4437 0BEA: MOVLW 89 5119 0E26: MOVWF 3F
4438 0BEB: MOVWF 04 5120 0E27: MOVF 2C,W
4439 0BEC: MOVF 2E,W 5121 0E28: MOVWF 3E
4440 0BED: MOVWF 38 5122 0E29: MOVF 2B,W
4441 0BEE: MOVF 2D,W 5123 0E2A: MOVWF 3D
4442 0BEF: MOVWF 37 5124 0E2B: MOVLW 02
4443 0BF0: MOVF 2C,W 5125 0E2C: MOVWF 41
4444 0BF1: MOVWF 36 5126 0E2D: CALL 2CB
4445 0BF2: MOVF 2B,W 5127 0E2E: MOVLW B2
4446 0BF3: MOVWF 35 5128 0E2F: MOVWF 4A
4447 0BF4: MOVLW 02 5129 0E30: BCF 0A.3
4448 0BF5: MOVWF 39 5130 0E31: CALL 212
4449 0BF6: CALL 091 5131 0E32: BSF 0A.3
4450 0BF7: MOVLW 20 5132 0E33: MOVLW 43
4451 0BF8: MOVWF 42 5133 0E34: MOVWF 4A
4452 0BF9: BCF 0A.3 5134 0E35: BCF 0A.3
4453 0BFA: CALL 212 5135 0E36: CALL 212
4454 0BFB: BSF 0A.3 5136 0E37: BSF 0A.3
4455 0BFC: MOVLW 43 5137 0E38: MOVLW 20
4456 0BFD: MOVWF 42 5138 0E39: MOVWF 4A
4457 0BFE: BCF 0A.3 5139 0E3A: BCF 0A.3
4458 0BFF: CALL 212 5140 0E3B: CALL 212
4459 0C00: BSF 0A.3 5141 0E3C: BSF 0A.3
4460 .................... printf("%ld %f %f %f ",i, temp1, humidity, temp2); 5142 0E3D: MOVLW 05
4461 0C01: MOVLW 10 5143 0E3E: MOVWF 04
4462 0C02: MOVWF 04 5144 0E3F: MOVF 3A,W
4463 0C03: MOVF 34,W 5145 0E40: MOVWF 40
4464 0C04: MOVWF 36 5146 0E41: MOVF 39,W
4465 0C05: MOVF 33,W 5147 0E42: MOVWF 3F
4466 0C06: MOVWF 35 5148 0E43: MOVF 38,W
4467 0C07: CALL 16B 5149 0E44: MOVWF 3E
4468 0C08: MOVLW 20 5150 0E45: MOVF 37,W
4469 0C09: BTFSS 0C.4 5151 0E46: MOVWF 3D
4470 0C0A: GOTO 409 5152 0E47: CLRF 41
4471 0C0B: MOVWF 19 5153 0E48: CALL 2CB
4472 0C0C: MOVLW 89 5154 0E49: MOVLW 50
4473 0C0D: MOVWF 04 5155 0E4A: MOVWF 4A
4474 0C0E: MOVF 2A,W 5156 0E4B: BCF 0A.3
4475 0C0F: MOVWF 38 5157 0E4C: CALL 212
4476 0C10: MOVF 29,W 5158 0E4D: BSF 0A.3
4477 0C11: MOVWF 37 5159 0E4E: MOVLW 61
4478 0C12: MOVF 28,W 5160 0E4F: MOVWF 4A
4479 0C13: MOVWF 36 5161 0E50: BCF 0A.3
4480 0C14: MOVF 27,W 5162 0E51: CALL 212
4481 0C15: MOVWF 35 5163 0E52: BSF 0A.3
4482 0C16: MOVLW 02 5164 0E53: MOVLW 20
4483 0C17: MOVWF 39 5165 0E54: MOVWF 4A
4484 0C18: CALL 1E1 5166 0E55: BCF 0A.3
4485 0C19: MOVLW 20 5167 0E56: CALL 212
4486 0C1A: BTFSS 0C.4 5168 0E57: BSF 0A.3
4487 0C1B: GOTO 41A 5169 ....................
4488 0C1C: MOVWF 19 5170 .................... printf("%ld %f %f %f %6.2f %3.2f %Ld %Ld %Ld \n\r",i, temp1, humidity, temp2, preasure, temp3, compass.x, compass.y, compass.z);
4489 0C1D: MOVLW 89 5171 0E58: MOVLW 10
4490 0C1E: MOVWF 04 5172 0E59: MOVWF 04
4491 0C1F: MOVF 32,W 5173 0E5A: MOVF 3C,W
4492 0C20: MOVWF 38 5174 0E5B: MOVWF 3E
4493 0C21: MOVF 31,W 5175 0E5C: MOVF 3B,W
4494 0C22: MOVWF 37 5176 0E5D: MOVWF 3D
4495 0C23: MOVF 30,W 5177 0E5E: CALL 39F
4496 0C24: MOVWF 36 5178 0E5F: MOVLW 20
4497 0C25: MOVF 2F,W 5179 0E60: BTFSS 0C.4
4498 0C26: MOVWF 35 5180 0E61: GOTO 660
4499 0C27: MOVLW 02 5181 0E62: MOVWF 19
4500 0C28: MOVWF 39 5182 0E63: MOVLW 89
4501 0C29: CALL 1E1 5183 0E64: MOVWF 04
4502 0C2A: MOVLW 20 5184 0E65: MOVF 2A,W
4503 0C2B: BTFSS 0C.4 5185 0E66: MOVWF 40
4504 0C2C: GOTO 42B 5186 0E67: MOVF 29,W
4505 0C2D: MOVWF 19 5187 0E68: MOVWF 3F
4506 0C2E: MOVLW 89 5188 0E69: MOVF 28,W
4507 0C2F: MOVWF 04 5189 0E6A: MOVWF 3E
4508 0C30: MOVF 2E,W 5190 0E6B: MOVF 27,W
4509 0C31: MOVWF 38 5191 0E6C: MOVWF 3D
4510 0C32: MOVF 2D,W 5192 0E6D: MOVLW 02
4511 0C33: MOVWF 37 5193 0E6E: MOVWF 41
4512 0C34: MOVF 2C,W 5194 0E6F: CALL 415
4513 0C35: MOVWF 36 5195 0E70: MOVLW 20
4514 0C36: MOVF 2B,W 5196 0E71: BTFSS 0C.4
4515 0C37: MOVWF 35 5197 0E72: GOTO 671
4516 0C38: MOVLW 02 5198 0E73: MOVWF 19
4517 0C39: MOVWF 39 5199 0E74: MOVLW 89
4518 0C3A: CALL 1E1 5200 0E75: MOVWF 04
4519 0C3B: MOVLW 20 5201 0E76: MOVF 36,W
4520 0C3C: BTFSS 0C.4 5202 0E77: MOVWF 40
4521 0C3D: GOTO 43C 5203 0E78: MOVF 35,W
4522 0C3E: MOVWF 19 5204 0E79: MOVWF 3F
4523 .................... printf("%Ld %Ld %Ld \n\r", compass.x, compass.y, compass.z); 5205 0E7A: MOVF 34,W
4524 0C3F: MOVLW 10 5206 0E7B: MOVWF 3E
4525 0C40: MOVWF 04 5207 0E7C: MOVF 33,W
4526 0C41: MOVF 22,W 5208 0E7D: MOVWF 3D
4527 0C42: MOVWF 36 5209 0E7E: MOVLW 02
4528 0C43: MOVF 21,W 5210 0E7F: MOVWF 41
4529 0C44: MOVWF 35 5211 0E80: CALL 415
4530 0C45: CALL 16B 5212 0E81: MOVLW 20
4531 0C46: MOVLW 20 5213 0E82: BTFSS 0C.4
4532 0C47: BTFSS 0C.4 5214 0E83: GOTO 682
4533 0C48: GOTO 447 5215 0E84: MOVWF 19
4534 0C49: MOVWF 19 5216 0E85: MOVLW 89
4535 0C4A: MOVLW 10 5217 0E86: MOVWF 04
4536 0C4B: MOVWF 04 5218 0E87: MOVF 2E,W
4537 0C4C: MOVF 24,W 5219 0E88: MOVWF 40
4538 0C4D: MOVWF 36 5220 0E89: MOVF 2D,W
4539 0C4E: MOVF 23,W 5221 0E8A: MOVWF 3F
4540 0C4F: MOVWF 35 5222 0E8B: MOVF 2C,W
4541 0C50: CALL 16B 5223 0E8C: MOVWF 3E
4542 0C51: MOVLW 20 5224 0E8D: MOVF 2B,W
4543 0C52: BTFSS 0C.4 5225 0E8E: MOVWF 3D
4544 0C53: GOTO 452 5226 0E8F: MOVLW 02
4545 0C54: MOVWF 19 5227 0E90: MOVWF 41
4546 0C55: MOVLW 10 5228 0E91: CALL 415
4547 0C56: MOVWF 04 5229 0E92: MOVLW 20
4548 0C57: MOVF 26,W 5230 0E93: BTFSS 0C.4
4549 0C58: MOVWF 36 5231 0E94: GOTO 693
4550 0C59: MOVF 25,W 5232 0E95: MOVWF 19
4551 0C5A: MOVWF 35 5233 0E96: MOVLW 05
4552 0C5B: CALL 16B 5234 0E97: MOVWF 04
4553 0C5C: MOVLW 20 5235 0E98: MOVF 3A,W
4554 0C5D: BTFSS 0C.4 5236 0E99: MOVWF 40
4555 0C5E: GOTO 45D 5237 0E9A: MOVF 39,W
4556 0C5F: MOVWF 19 5238 0E9B: MOVWF 3F
4557 0C60: MOVLW 0A 5239 0E9C: MOVF 38,W
4558 0C61: BTFSS 0C.4 5240 0E9D: MOVWF 3E
4559 0C62: GOTO 461 5241 0E9E: MOVF 37,W
4560 0C63: MOVWF 19 5242 0E9F: MOVWF 3D
4561 0C64: MOVLW 0D 5243 0EA0: MOVLW 02
4562 0C65: BTFSS 0C.4 5244 0EA1: MOVWF 41
4563 0C66: GOTO 465 5245 0EA2: CALL 415
4564 0C67: MOVWF 19 5246 0EA3: MOVLW 20
-   5247 0EA4: BTFSS 0C.4
-   5248 0EA5: GOTO 6A4
-   5249 0EA6: MOVWF 19
-   5250 0EA7: MOVLW 02
-   5251 0EA8: MOVWF 04
-   5252 0EA9: MOVF 32,W
-   5253 0EAA: MOVWF 40
-   5254 0EAB: MOVF 31,W
-   5255 0EAC: MOVWF 3F
-   5256 0EAD: MOVF 30,W
-   5257 0EAE: MOVWF 3E
-   5258 0EAF: MOVF 2F,W
-   5259 0EB0: MOVWF 3D
-   5260 0EB1: MOVLW 02
-   5261 0EB2: MOVWF 41
-   5262 0EB3: CALL 415
-   5263 0EB4: MOVLW 20
-   5264 0EB5: BTFSS 0C.4
-   5265 0EB6: GOTO 6B5
-   5266 0EB7: MOVWF 19
-   5267 0EB8: MOVLW 10
-   5268 0EB9: MOVWF 04
-   5269 0EBA: MOVF 22,W
-   5270 0EBB: MOVWF 3E
-   5271 0EBC: MOVF 21,W
-   5272 0EBD: MOVWF 3D
-   5273 0EBE: CALL 39F
-   5274 0EBF: MOVLW 20
-   5275 0EC0: BTFSS 0C.4
-   5276 0EC1: GOTO 6C0
-   5277 0EC2: MOVWF 19
-   5278 0EC3: MOVLW 10
-   5279 0EC4: MOVWF 04
-   5280 0EC5: MOVF 24,W
-   5281 0EC6: MOVWF 3E
-   5282 0EC7: MOVF 23,W
-   5283 0EC8: MOVWF 3D
-   5284 0EC9: CALL 39F
-   5285 0ECA: MOVLW 20
-   5286 0ECB: BTFSS 0C.4
-   5287 0ECC: GOTO 6CB
-   5288 0ECD: MOVWF 19
-   5289 0ECE: MOVLW 10
-   5290 0ECF: MOVWF 04
-   5291 0ED0: MOVF 26,W
-   5292 0ED1: MOVWF 3E
-   5293 0ED2: MOVF 25,W
-   5294 0ED3: MOVWF 3D
-   5295 0ED4: CALL 39F
-   5296 0ED5: MOVLW 20
-   5297 0ED6: BTFSS 0C.4
-   5298 0ED7: GOTO 6D6
-   5299 0ED8: MOVWF 19
-   5300 0ED9: MOVLW 0A
-   5301 0EDA: BTFSS 0C.4
-   5302 0EDB: GOTO 6DA
-   5303 0EDC: MOVWF 19
-   5304 0EDD: MOVLW 0D
-   5305 0EDE: BTFSS 0C.4
-   5306 0EDF: GOTO 6DE
-   5307 0EE0: MOVWF 19
4565 .................... i++; 5308 .................... i++;
4566 0C68: INCF 33,F 5309 0EE1: INCF 3B,F
4567 0C69: BTFSC 03.2 5310 0EE2: BTFSC 03.2
4568 0C6A: INCF 34,F 5311 0EE3: INCF 3C,F
-   5312 ....................
4569 .................... Delay_ms(100); 5313 .................... Delay_ms(100);
4570 0C6B: MOVLW 64 5314 0EE4: MOVLW 64
4571 0C6C: MOVWF 43 5315 0EE5: MOVWF 4B
4572 0C6D: BCF 0A.3 5316 0EE6: BCF 0A.3
4573 0C6E: CALL 0FB 5317 0EE7: CALL 0FB
4574 0C6F: BSF 0A.3 5318 0EE8: BSF 0A.3
4575 .................... } 5319 .................... }
4576 0C70: GOTO 383 5320 0EE9: GOTO 5B1
4577 .................... 5321 ....................
4578 .................... } 5322 .................... }
4579 0C71: SLEEP 5323 0EEA: SLEEP
4580   5324  
4581 Configuration Fuses: 5325 Configuration Fuses:
4582 Word 1: 2CF5 INTRC NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP NODEBUG 5326 Word 1: 2CF5 INTRC NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP NODEBUG
4583 Word 2: 3FFF NOWRT BORV40 5327 Word 2: 3FFF NOWRT BORV40