3286 |
kaklik |
1 |
CCS PCM C Compiler, Version 4.106, 47914 10-IX-13 13:59 |
3275 |
kaklik |
2 |
|
3286 |
kaklik |
3 |
Filename: Z:\home\kaklik\svnMLAB\Designs\Measuring_instruments\GeoMet01A\SW\PIC16F887\main.lst |
3275 |
kaklik |
4 |
|
3286 |
kaklik |
5 |
ROM used: 3809 words (46%) |
3275 |
kaklik |
6 |
Largest free fragment is 2048 |
3286 |
kaklik |
7 |
RAM used: 35 (10%) at main() level |
|
|
8 |
72 (20%) worst case |
3275 |
kaklik |
9 |
Stack: 5 locations |
|
|
10 |
|
|
|
11 |
* |
3286 |
kaklik |
12 |
0000: MOVLW 0C |
3275 |
kaklik |
13 |
0001: MOVWF 0A |
3286 |
kaklik |
14 |
0002: GOTO 4E5 |
3275 |
kaklik |
15 |
0003: NOP |
|
|
16 |
.................... #include "main.h" |
|
|
17 |
.................... #include <16F887.h> |
|
|
18 |
.................... //////// Standard Header file for the PIC16F887 device //////////////// |
|
|
19 |
.................... #device PIC16F887 |
|
|
20 |
.................... #list |
|
|
21 |
.................... |
|
|
22 |
.................... #device adc=10 |
|
|
23 |
.................... |
|
|
24 |
.................... #FUSES NOWDT //No Watch Dog Timer |
|
|
25 |
.................... #FUSES INTRC //Internal RC Osc |
|
|
26 |
.................... #FUSES NOPUT //No Power Up Timer |
|
|
27 |
.................... #FUSES MCLR //Master Clear pin enabled |
|
|
28 |
.................... #FUSES NOPROTECT //Code not protected from reading |
|
|
29 |
.................... #FUSES NOCPD //No EE protection |
|
|
30 |
.................... #FUSES NOBROWNOUT //No brownout reset |
|
|
31 |
.................... #FUSES IESO //Internal External Switch Over mode 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 |
|
|
34 |
.................... #FUSES NODEBUG //No Debug mode for ICD |
|
|
35 |
.................... #FUSES NOWRT //Program memory not write protected |
|
|
36 |
.................... #FUSES BORV40 //Brownout reset at 4.0V |
|
|
37 |
.................... |
|
|
38 |
.................... #use delay(clock=8000000) |
|
|
39 |
* |
3286 |
kaklik |
40 |
00FB: MOVLW 4B |
3283 |
kakl |
41 |
00FC: MOVWF 04 |
|
|
42 |
00FD: BCF 03.7 |
|
|
43 |
00FE: MOVF 00,W |
|
|
44 |
00FF: BTFSC 03.2 |
|
|
45 |
0100: GOTO 10E |
|
|
46 |
0101: MOVLW 02 |
|
|
47 |
0102: MOVWF 78 |
|
|
48 |
0103: CLRF 77 |
|
|
49 |
0104: DECFSZ 77,F |
|
|
50 |
0105: GOTO 104 |
|
|
51 |
0106: DECFSZ 78,F |
|
|
52 |
0107: GOTO 103 |
|
|
53 |
0108: MOVLW 97 |
|
|
54 |
0109: MOVWF 77 |
|
|
55 |
010A: DECFSZ 77,F |
|
|
56 |
010B: GOTO 10A |
|
|
57 |
010C: DECFSZ 00,F |
|
|
58 |
010D: GOTO 101 |
|
|
59 |
010E: RETURN |
3275 |
kaklik |
60 |
.................... #use i2c(master, sda=PIN_C4, scl=PIN_C3) |
|
|
61 |
* |
3283 |
kakl |
62 |
0078: MOVLW 08 |
|
|
63 |
0079: MOVWF 78 |
|
|
64 |
007A: NOP |
|
|
65 |
007B: BCF 07.3 |
|
|
66 |
007C: BCF 20.3 |
|
|
67 |
007D: MOVF 20,W |
|
|
68 |
007E: BSF 03.5 |
|
|
69 |
007F: MOVWF 07 |
|
|
70 |
0080: NOP |
|
|
71 |
0081: BCF 03.5 |
3286 |
kaklik |
72 |
0082: RLF 4E,F |
3283 |
kakl |
73 |
0083: BCF 07.4 |
|
|
74 |
0084: BTFSS 03.0 |
|
|
75 |
0085: GOTO 08C |
|
|
76 |
0086: BSF 20.4 |
|
|
77 |
0087: MOVF 20,W |
|
|
78 |
0088: BSF 03.5 |
|
|
79 |
0089: MOVWF 07 |
|
|
80 |
008A: GOTO 090 |
|
|
81 |
008B: BCF 03.5 |
|
|
82 |
008C: BCF 20.4 |
|
|
83 |
008D: MOVF 20,W |
|
|
84 |
008E: BSF 03.5 |
|
|
85 |
008F: MOVWF 07 |
|
|
86 |
0090: NOP |
|
|
87 |
0091: BCF 03.5 |
|
|
88 |
0092: BSF 20.3 |
|
|
89 |
0093: MOVF 20,W |
|
|
90 |
0094: BSF 03.5 |
|
|
91 |
0095: MOVWF 07 |
|
|
92 |
0096: BCF 03.5 |
|
|
93 |
0097: BTFSS 07.3 |
|
|
94 |
0098: GOTO 097 |
|
|
95 |
0099: DECFSZ 78,F |
|
|
96 |
009A: GOTO 07A |
|
|
97 |
009B: NOP |
|
|
98 |
009C: BCF 07.3 |
|
|
99 |
009D: BCF 20.3 |
|
|
100 |
009E: MOVF 20,W |
|
|
101 |
009F: BSF 03.5 |
|
|
102 |
00A0: MOVWF 07 |
|
|
103 |
00A1: NOP |
|
|
104 |
00A2: BCF 03.5 |
|
|
105 |
00A3: BSF 20.4 |
|
|
106 |
00A4: MOVF 20,W |
|
|
107 |
00A5: BSF 03.5 |
|
|
108 |
00A6: MOVWF 07 |
|
|
109 |
00A7: NOP |
|
|
110 |
00A8: NOP |
|
|
111 |
00A9: BCF 03.5 |
|
|
112 |
00AA: BSF 20.3 |
|
|
113 |
00AB: MOVF 20,W |
|
|
114 |
00AC: BSF 03.5 |
|
|
115 |
00AD: MOVWF 07 |
|
|
116 |
00AE: BCF 03.5 |
|
|
117 |
00AF: BTFSS 07.3 |
|
|
118 |
00B0: GOTO 0AF |
|
|
119 |
00B1: CLRF 78 |
|
|
120 |
00B2: NOP |
|
|
121 |
00B3: BTFSC 07.4 |
|
|
122 |
00B4: BSF 78.0 |
|
|
123 |
00B5: BCF 07.3 |
|
|
124 |
00B6: BCF 20.3 |
|
|
125 |
00B7: MOVF 20,W |
|
|
126 |
00B8: BSF 03.5 |
|
|
127 |
00B9: MOVWF 07 |
|
|
128 |
00BA: BCF 03.5 |
|
|
129 |
00BB: BCF 07.4 |
|
|
130 |
00BC: BCF 20.4 |
|
|
131 |
00BD: MOVF 20,W |
|
|
132 |
00BE: BSF 03.5 |
|
|
133 |
00BF: MOVWF 07 |
|
|
134 |
00C0: BCF 03.5 |
|
|
135 |
00C1: RETURN |
|
|
136 |
* |
|
|
137 |
0285: MOVLW 08 |
3286 |
kaklik |
138 |
0286: MOVWF 4F |
3283 |
kakl |
139 |
0287: MOVF 77,W |
3286 |
kaklik |
140 |
0288: MOVWF 50 |
3283 |
kakl |
141 |
0289: BSF 20.4 |
|
|
142 |
028A: MOVF 20,W |
|
|
143 |
028B: BSF 03.5 |
|
|
144 |
028C: MOVWF 07 |
|
|
145 |
028D: NOP |
|
|
146 |
028E: BCF 03.5 |
|
|
147 |
028F: BSF 20.3 |
|
|
148 |
0290: MOVF 20,W |
|
|
149 |
0291: BSF 03.5 |
|
|
150 |
0292: MOVWF 07 |
|
|
151 |
0293: BCF 03.5 |
|
|
152 |
0294: BTFSS 07.3 |
|
|
153 |
0295: GOTO 294 |
|
|
154 |
0296: BTFSC 07.4 |
|
|
155 |
0297: BSF 03.0 |
|
|
156 |
0298: BTFSS 07.4 |
|
|
157 |
0299: BCF 03.0 |
|
|
158 |
029A: RLF 78,F |
|
|
159 |
029B: NOP |
|
|
160 |
029C: BCF 20.3 |
|
|
161 |
029D: MOVF 20,W |
|
|
162 |
029E: BSF 03.5 |
|
|
163 |
029F: MOVWF 07 |
|
|
164 |
02A0: BCF 03.5 |
|
|
165 |
02A1: BCF 07.3 |
3286 |
kaklik |
166 |
02A2: DECFSZ 4F,F |
3283 |
kakl |
167 |
02A3: GOTO 289 |
|
|
168 |
02A4: BSF 20.4 |
|
|
169 |
02A5: MOVF 20,W |
|
|
170 |
02A6: BSF 03.5 |
|
|
171 |
02A7: MOVWF 07 |
|
|
172 |
02A8: NOP |
|
|
173 |
02A9: BCF 03.5 |
|
|
174 |
02AA: BCF 07.4 |
3286 |
kaklik |
175 |
02AB: MOVF 50,W |
3283 |
kakl |
176 |
02AC: BTFSC 03.2 |
|
|
177 |
02AD: GOTO 2B3 |
|
|
178 |
02AE: BCF 20.4 |
|
|
179 |
02AF: MOVF 20,W |
|
|
180 |
02B0: BSF 03.5 |
|
|
181 |
02B1: MOVWF 07 |
|
|
182 |
02B2: BCF 03.5 |
|
|
183 |
02B3: NOP |
|
|
184 |
02B4: BSF 20.3 |
|
|
185 |
02B5: MOVF 20,W |
|
|
186 |
02B6: BSF 03.5 |
|
|
187 |
02B7: MOVWF 07 |
|
|
188 |
02B8: BCF 03.5 |
|
|
189 |
02B9: BTFSS 07.3 |
|
|
190 |
02BA: GOTO 2B9 |
|
|
191 |
02BB: NOP |
|
|
192 |
02BC: BCF 07.3 |
|
|
193 |
02BD: BCF 20.3 |
|
|
194 |
02BE: MOVF 20,W |
|
|
195 |
02BF: BSF 03.5 |
|
|
196 |
02C0: MOVWF 07 |
|
|
197 |
02C1: NOP |
|
|
198 |
02C2: BCF 03.5 |
|
|
199 |
02C3: BCF 07.4 |
|
|
200 |
02C4: BCF 20.4 |
|
|
201 |
02C5: MOVF 20,W |
|
|
202 |
02C6: BSF 03.5 |
|
|
203 |
02C7: MOVWF 07 |
|
|
204 |
02C8: BCF 03.5 |
|
|
205 |
02C9: RETURN |
3275 |
kaklik |
206 |
.................... #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8) |
|
|
207 |
.................... |
|
|
208 |
.................... |
|
|
209 |
.................... |
|
|
210 |
.................... #define LCD_ENABLE_PIN PIN_E0 //// |
|
|
211 |
.................... #define LCD_RS_PIN PIN_E1 //// |
|
|
212 |
.................... #define LCD_RW_PIN PIN_E2 //// |
|
|
213 |
.................... #define LCD_DATA4 PIN_D4 //// |
|
|
214 |
.................... #define LCD_DATA5 PIN_D5 //// |
|
|
215 |
.................... #define LCD_DATA6 PIN_D6 //// |
|
|
216 |
.................... #define LCD_DATA7 PIN_D7 |
|
|
217 |
.................... #include <lcd.c> |
|
|
218 |
.................... /////////////////////////////////////////////////////////////////////////////// |
|
|
219 |
.................... //// LCD.C //// |
|
|
220 |
.................... //// Driver for common LCD modules //// |
|
|
221 |
.................... //// //// |
|
|
222 |
.................... //// lcd_init() Must be called before any other function. //// |
|
|
223 |
.................... //// //// |
|
|
224 |
.................... //// lcd_putc(c) Will display c on the next position of the LCD. //// |
|
|
225 |
.................... //// \a Set cursor position to upper left //// |
|
|
226 |
.................... //// \f Clear display, set cursor to upper left //// |
|
|
227 |
.................... //// \n Go to start of second line //// |
|
|
228 |
.................... //// \b Move back one position //// |
|
|
229 |
.................... //// If LCD_EXTENDED_NEWLINE is defined, the \n character //// |
|
|
230 |
.................... //// will erase all remanining characters on the current //// |
|
|
231 |
.................... //// line, and move the cursor to the beginning of the next //// |
|
|
232 |
.................... //// line. //// |
|
|
233 |
.................... //// If LCD_EXTENDED_NEWLINE is defined, the \r character //// |
|
|
234 |
.................... //// will move the cursor to the start of the current //// |
|
|
235 |
.................... //// line. //// |
|
|
236 |
.................... //// //// |
|
|
237 |
.................... //// lcd_gotoxy(x,y) Set write position on LCD (upper left is 1,1) //// |
|
|
238 |
.................... //// //// |
|
|
239 |
.................... //// lcd_getc(x,y) Returns character at position x,y on LCD //// |
|
|
240 |
.................... //// //// |
|
|
241 |
.................... //// CONFIGURATION //// |
|
|
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 //// |
|
|
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 //// |
|
|
246 |
.................... //// has no requirements, all 7 bits of the control interface can //// |
|
|
247 |
.................... //// can be connected to any GPIO using several ports. //// |
|
|
248 |
.................... //// //// |
|
|
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 //// |
|
|
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 //// |
|
|
253 |
.................... //// be defined. //// |
|
|
254 |
.................... //// //// |
|
|
255 |
.................... //// Example of port access: //// |
|
|
256 |
.................... //// #define LCD_DATA_PORT getenv("SFR:PORTD") //// |
|
|
257 |
.................... //// //// |
|
|
258 |
.................... //// To use pin access, the following pins must be defined: //// |
|
|
259 |
.................... //// LCD_ENABLE_PIN //// |
|
|
260 |
.................... //// LCD_RS_PIN //// |
|
|
261 |
.................... //// LCD_RW_PIN //// |
|
|
262 |
.................... //// LCD_DATA4 //// |
|
|
263 |
.................... //// LCD_DATA5 //// |
|
|
264 |
.................... //// LCD_DATA6 //// |
|
|
265 |
.................... //// LCD_DATA7 //// |
|
|
266 |
.................... //// //// |
|
|
267 |
.................... //// Example of pin access: //// |
|
|
268 |
.................... //// #define LCD_ENABLE_PIN PIN_E0 //// |
|
|
269 |
.................... //// #define LCD_RS_PIN PIN_E1 //// |
|
|
270 |
.................... //// #define LCD_RW_PIN PIN_E2 //// |
|
|
271 |
.................... //// #define LCD_DATA4 PIN_D4 //// |
|
|
272 |
.................... //// #define LCD_DATA5 PIN_D5 //// |
|
|
273 |
.................... //// #define LCD_DATA6 PIN_D6 //// |
|
|
274 |
.................... //// #define LCD_DATA7 PIN_D7 //// |
|
|
275 |
.................... //// //// |
|
|
276 |
.................... /////////////////////////////////////////////////////////////////////////////// |
|
|
277 |
.................... //// (C) Copyright 1996,2010 Custom Computer Services //// |
|
|
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 //// |
|
|
280 |
.................... //// licensed users of the CCS C compiler. No other use, reproduction //// |
|
|
281 |
.................... //// or distribution is permitted without written permission. //// |
|
|
282 |
.................... //// Derivative programs created using this software in object code //// |
|
|
283 |
.................... //// form are not restricted in any way. //// |
|
|
284 |
.................... /////////////////////////////////////////////////////////////////////////// |
|
|
285 |
.................... |
|
|
286 |
.................... // define the pinout. |
|
|
287 |
.................... // only required if port access is being used. |
|
|
288 |
.................... typedef struct |
|
|
289 |
.................... { // This structure is overlayed |
|
|
290 |
.................... BOOLEAN enable; // on to an I/O port to gain |
|
|
291 |
.................... BOOLEAN rs; // access to the LCD pins. |
|
|
292 |
.................... BOOLEAN rw; // The bits are allocated from |
|
|
293 |
.................... BOOLEAN unused; // low order up. ENABLE will |
|
|
294 |
.................... int data : 4; // be LSB pin of that port. |
|
|
295 |
.................... #if defined(__PCD__) // The port used will be LCD_DATA_PORT. |
|
|
296 |
.................... int reserved: 8; |
|
|
297 |
.................... #endif |
|
|
298 |
.................... } LCD_PIN_MAP; |
|
|
299 |
.................... |
|
|
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. |
|
|
302 |
.................... #if ((defined(use_portb_lcd)) && (use_portb_lcd==TRUE)) |
|
|
303 |
.................... #define LCD_DATA_PORT getenv("SFR:PORTB") |
|
|
304 |
.................... #endif |
|
|
305 |
.................... |
|
|
306 |
.................... #if defined(__PCB__) |
|
|
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. |
|
|
309 |
.................... /* EN, RS, RW, UNUSED, DATA */ |
|
|
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}; |
|
|
312 |
.................... #endif |
|
|
313 |
.................... |
|
|
314 |
.................... ////////////////////// END CONFIGURATION /////////////////////////////////// |
|
|
315 |
.................... |
|
|
316 |
.................... #ifndef LCD_ENABLE_PIN |
|
|
317 |
.................... #define lcd_output_enable(x) lcdlat.enable=x |
|
|
318 |
.................... #define lcd_enable_tris() lcdtris.enable=0 |
|
|
319 |
.................... #else |
|
|
320 |
.................... #define lcd_output_enable(x) output_bit(LCD_ENABLE_PIN, x) |
|
|
321 |
.................... #define lcd_enable_tris() output_drive(LCD_ENABLE_PIN) |
|
|
322 |
.................... #endif |
|
|
323 |
.................... |
|
|
324 |
.................... #ifndef LCD_RS_PIN |
|
|
325 |
.................... #define lcd_output_rs(x) lcdlat.rs=x |
|
|
326 |
.................... #define lcd_rs_tris() lcdtris.rs=0 |
|
|
327 |
.................... #else |
|
|
328 |
.................... #define lcd_output_rs(x) output_bit(LCD_RS_PIN, x) |
|
|
329 |
.................... #define lcd_rs_tris() output_drive(LCD_RS_PIN) |
|
|
330 |
.................... #endif |
|
|
331 |
.................... |
|
|
332 |
.................... #ifndef LCD_RW_PIN |
|
|
333 |
.................... #define lcd_output_rw(x) lcdlat.rw=x |
|
|
334 |
.................... #define lcd_rw_tris() lcdtris.rw=0 |
|
|
335 |
.................... #else |
|
|
336 |
.................... #define lcd_output_rw(x) output_bit(LCD_RW_PIN, x) |
|
|
337 |
.................... #define lcd_rw_tris() output_drive(LCD_RW_PIN) |
|
|
338 |
.................... #endif |
|
|
339 |
.................... |
|
|
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 |
|
|
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)) |
|
|
344 |
.................... #define LCD_DATA4 LCD_DATA0 |
|
|
345 |
.................... #define LCD_DATA5 LCD_DATA1 |
|
|
346 |
.................... #define LCD_DATA6 LCD_DATA2 |
|
|
347 |
.................... #define LCD_DATA7 LCD_DATA3 |
|
|
348 |
.................... #endif |
|
|
349 |
.................... |
|
|
350 |
.................... #ifndef LCD_DATA4 |
|
|
351 |
.................... #ifndef LCD_DATA_PORT |
|
|
352 |
.................... #if defined(__PCB__) |
|
|
353 |
.................... #define LCD_DATA_PORT 0x06 //portb |
|
|
354 |
.................... #define set_tris_lcd(x) set_tris_b(x) |
|
|
355 |
.................... #else |
|
|
356 |
.................... #if defined(PIN_D0) |
|
|
357 |
.................... #define LCD_DATA_PORT getenv("SFR:PORTD") //portd |
|
|
358 |
.................... #else |
|
|
359 |
.................... #define LCD_DATA_PORT getenv("SFR:PORTB") //portb |
|
|
360 |
.................... #endif |
|
|
361 |
.................... #endif |
|
|
362 |
.................... #endif |
|
|
363 |
.................... |
|
|
364 |
.................... #if defined(__PCB__) |
|
|
365 |
.................... LCD_PIN_MAP lcd, lcdlat; |
|
|
366 |
.................... #byte lcd = LCD_DATA_PORT |
|
|
367 |
.................... #byte lcdlat = LCD_DATA_PORT |
|
|
368 |
.................... #elif defined(__PCM__) |
|
|
369 |
.................... LCD_PIN_MAP lcd, lcdlat, lcdtris; |
|
|
370 |
.................... #byte lcd = LCD_DATA_PORT |
|
|
371 |
.................... #byte lcdlat = LCD_DATA_PORT |
|
|
372 |
.................... #byte lcdtris = LCD_DATA_PORT+0x80 |
|
|
373 |
.................... #elif defined(__PCH__) |
|
|
374 |
.................... LCD_PIN_MAP lcd, lcdlat, lcdtris; |
|
|
375 |
.................... #byte lcd = LCD_DATA_PORT |
|
|
376 |
.................... #byte lcdlat = LCD_DATA_PORT+9 |
|
|
377 |
.................... #byte lcdtris = LCD_DATA_PORT+0x12 |
|
|
378 |
.................... #elif defined(__PCD__) |
|
|
379 |
.................... LCD_PIN_MAP lcd, lcdlat, lcdtris; |
|
|
380 |
.................... #word lcd = LCD_DATA_PORT |
|
|
381 |
.................... #word lcdlat = LCD_DATA_PORT+2 |
|
|
382 |
.................... #word lcdtris = LCD_DATA_PORT-0x02 |
|
|
383 |
.................... #endif |
|
|
384 |
.................... #endif //LCD_DATA4 not defined |
|
|
385 |
.................... |
|
|
386 |
.................... #ifndef LCD_TYPE |
|
|
387 |
.................... #define LCD_TYPE 2 // 0=5x7, 1=5x10, 2=2 lines |
|
|
388 |
.................... #endif |
|
|
389 |
.................... |
|
|
390 |
.................... #ifndef LCD_LINE_TWO |
|
|
391 |
.................... #define LCD_LINE_TWO 0x40 // LCD RAM address for the second line |
|
|
392 |
.................... #endif |
|
|
393 |
.................... |
|
|
394 |
.................... #ifndef LCD_LINE_LENGTH |
|
|
395 |
.................... #define LCD_LINE_LENGTH 20 |
|
|
396 |
.................... #endif |
|
|
397 |
.................... |
|
|
398 |
.................... BYTE const LCD_INIT_STRING[4] = {0x20 | (LCD_TYPE << 2), 0xc, 1, 6}; |
|
|
399 |
.................... // These bytes need to be sent to the LCD |
|
|
400 |
.................... // to start it up. |
|
|
401 |
.................... |
|
|
402 |
.................... BYTE lcd_read_nibble(void); |
|
|
403 |
.................... |
|
|
404 |
.................... BYTE lcd_read_byte(void) |
|
|
405 |
.................... { |
|
|
406 |
.................... BYTE low,high; |
|
|
407 |
.................... |
|
|
408 |
.................... #if defined(__PCB__) |
|
|
409 |
.................... set_tris_lcd(LCD_INPUT_MAP); |
|
|
410 |
.................... #else |
|
|
411 |
.................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7)) |
|
|
412 |
.................... output_float(LCD_DATA4); |
|
|
413 |
* |
3283 |
kakl |
414 |
0174: BSF 08.4 |
3275 |
kaklik |
415 |
.................... output_float(LCD_DATA5); |
3283 |
kakl |
416 |
0175: BSF 08.5 |
3275 |
kaklik |
417 |
.................... output_float(LCD_DATA6); |
3283 |
kakl |
418 |
0176: BSF 08.6 |
3275 |
kaklik |
419 |
.................... output_float(LCD_DATA7); |
3283 |
kakl |
420 |
0177: BSF 08.7 |
3275 |
kaklik |
421 |
.................... #else |
|
|
422 |
.................... lcdtris.data = 0xF; |
|
|
423 |
.................... #endif |
|
|
424 |
.................... #endif |
|
|
425 |
.................... |
|
|
426 |
.................... lcd_output_rw(1); |
3283 |
kakl |
427 |
0178: BCF 03.5 |
|
|
428 |
0179: BSF 09.2 |
|
|
429 |
017A: BSF 03.5 |
|
|
430 |
017B: BCF 09.2 |
3275 |
kaklik |
431 |
.................... delay_cycles(1); |
3283 |
kakl |
432 |
017C: NOP |
3275 |
kaklik |
433 |
.................... lcd_output_enable(1); |
3283 |
kakl |
434 |
017D: BCF 03.5 |
|
|
435 |
017E: BSF 09.0 |
|
|
436 |
017F: BSF 03.5 |
|
|
437 |
0180: BCF 09.0 |
3275 |
kaklik |
438 |
.................... delay_cycles(1); |
3283 |
kakl |
439 |
0181: NOP |
3275 |
kaklik |
440 |
.................... high = lcd_read_nibble(); |
3283 |
kakl |
441 |
0182: BCF 03.5 |
|
|
442 |
0183: CALL 13B |
|
|
443 |
0184: MOVF 78,W |
3286 |
kaklik |
444 |
0185: MOVWF 52 |
3275 |
kaklik |
445 |
.................... |
|
|
446 |
.................... lcd_output_enable(0); |
3283 |
kakl |
447 |
0186: BCF 09.0 |
|
|
448 |
0187: BSF 03.5 |
|
|
449 |
0188: BCF 09.0 |
3275 |
kaklik |
450 |
.................... delay_cycles(1); |
3283 |
kakl |
451 |
0189: NOP |
3275 |
kaklik |
452 |
.................... lcd_output_enable(1); |
3283 |
kakl |
453 |
018A: BCF 03.5 |
|
|
454 |
018B: BSF 09.0 |
|
|
455 |
018C: BSF 03.5 |
|
|
456 |
018D: BCF 09.0 |
3275 |
kaklik |
457 |
.................... delay_us(1); |
3283 |
kakl |
458 |
018E: GOTO 18F |
3275 |
kaklik |
459 |
.................... low = lcd_read_nibble(); |
3283 |
kakl |
460 |
018F: BCF 03.5 |
|
|
461 |
0190: CALL 13B |
|
|
462 |
0191: MOVF 78,W |
3286 |
kaklik |
463 |
0192: MOVWF 51 |
3275 |
kaklik |
464 |
.................... |
|
|
465 |
.................... lcd_output_enable(0); |
3283 |
kakl |
466 |
0193: BCF 09.0 |
|
|
467 |
0194: BSF 03.5 |
|
|
468 |
0195: BCF 09.0 |
3275 |
kaklik |
469 |
.................... |
|
|
470 |
.................... #if defined(__PCB__) |
|
|
471 |
.................... set_tris_lcd(LCD_OUTPUT_MAP); |
|
|
472 |
.................... #else |
|
|
473 |
.................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7)) |
|
|
474 |
.................... output_drive(LCD_DATA4); |
3283 |
kakl |
475 |
0196: BCF 08.4 |
3275 |
kaklik |
476 |
.................... output_drive(LCD_DATA5); |
3283 |
kakl |
477 |
0197: BCF 08.5 |
3275 |
kaklik |
478 |
.................... output_drive(LCD_DATA6); |
3283 |
kakl |
479 |
0198: BCF 08.6 |
3275 |
kaklik |
480 |
.................... output_drive(LCD_DATA7); |
3283 |
kakl |
481 |
0199: BCF 08.7 |
3275 |
kaklik |
482 |
.................... #else |
|
|
483 |
.................... lcdtris.data = 0x0; |
|
|
484 |
.................... #endif |
|
|
485 |
.................... #endif |
|
|
486 |
.................... |
|
|
487 |
.................... return( (high<<4) | low); |
3283 |
kakl |
488 |
019A: BCF 03.5 |
3286 |
kaklik |
489 |
019B: SWAPF 52,W |
3283 |
kakl |
490 |
019C: MOVWF 77 |
|
|
491 |
019D: MOVLW F0 |
|
|
492 |
019E: ANDWF 77,F |
|
|
493 |
019F: MOVF 77,W |
3286 |
kaklik |
494 |
01A0: IORWF 51,W |
3283 |
kakl |
495 |
01A1: MOVWF 78 |
3275 |
kaklik |
496 |
.................... } |
|
|
497 |
.................... |
|
|
498 |
.................... BYTE lcd_read_nibble(void) |
|
|
499 |
.................... { |
|
|
500 |
.................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7)) |
|
|
501 |
* |
3286 |
kaklik |
502 |
013B: CLRF 53 |
3275 |
kaklik |
503 |
.................... BYTE n = 0x00; |
|
|
504 |
.................... |
|
|
505 |
.................... /* Read the data port */ |
|
|
506 |
.................... n |= input(LCD_DATA4); |
3283 |
kakl |
507 |
013C: BSF 03.5 |
|
|
508 |
013D: BSF 08.4 |
|
|
509 |
013E: MOVLW 00 |
|
|
510 |
013F: BCF 03.5 |
|
|
511 |
0140: BTFSC 08.4 |
|
|
512 |
0141: MOVLW 01 |
3286 |
kaklik |
513 |
0142: IORWF 53,F |
3275 |
kaklik |
514 |
.................... n |= input(LCD_DATA5) << 1; |
3283 |
kakl |
515 |
0143: BSF 03.5 |
|
|
516 |
0144: BSF 08.5 |
|
|
517 |
0145: MOVLW 00 |
|
|
518 |
0146: BCF 03.5 |
|
|
519 |
0147: BTFSC 08.5 |
|
|
520 |
0148: MOVLW 01 |
|
|
521 |
0149: MOVWF 77 |
|
|
522 |
014A: BCF 03.0 |
|
|
523 |
014B: RLF 77,F |
|
|
524 |
014C: MOVF 77,W |
3286 |
kaklik |
525 |
014D: IORWF 53,F |
3275 |
kaklik |
526 |
.................... n |= input(LCD_DATA6) << 2; |
3283 |
kakl |
527 |
014E: BSF 03.5 |
|
|
528 |
014F: BSF 08.6 |
|
|
529 |
0150: MOVLW 00 |
|
|
530 |
0151: BCF 03.5 |
|
|
531 |
0152: BTFSC 08.6 |
|
|
532 |
0153: MOVLW 01 |
|
|
533 |
0154: MOVWF 77 |
|
|
534 |
0155: RLF 77,F |
|
|
535 |
0156: RLF 77,F |
|
|
536 |
0157: MOVLW FC |
|
|
537 |
0158: ANDWF 77,F |
|
|
538 |
0159: MOVF 77,W |
3286 |
kaklik |
539 |
015A: IORWF 53,F |
3275 |
kaklik |
540 |
.................... n |= input(LCD_DATA7) << 3; |
3283 |
kakl |
541 |
015B: BSF 03.5 |
|
|
542 |
015C: BSF 08.7 |
|
|
543 |
015D: MOVLW 00 |
|
|
544 |
015E: BCF 03.5 |
|
|
545 |
015F: BTFSC 08.7 |
|
|
546 |
0160: MOVLW 01 |
|
|
547 |
0161: MOVWF 77 |
|
|
548 |
0162: RLF 77,F |
|
|
549 |
0163: RLF 77,F |
|
|
550 |
0164: RLF 77,F |
|
|
551 |
0165: MOVLW F8 |
|
|
552 |
0166: ANDWF 77,F |
|
|
553 |
0167: MOVF 77,W |
3286 |
kaklik |
554 |
0168: IORWF 53,F |
3275 |
kaklik |
555 |
.................... |
|
|
556 |
.................... return(n); |
3286 |
kaklik |
557 |
0169: MOVF 53,W |
3283 |
kakl |
558 |
016A: MOVWF 78 |
3275 |
kaklik |
559 |
.................... #else |
|
|
560 |
.................... return(lcd.data); |
|
|
561 |
.................... #endif |
|
|
562 |
.................... } |
3283 |
kakl |
563 |
016B: RETURN |
3275 |
kaklik |
564 |
.................... |
|
|
565 |
.................... void lcd_send_nibble(BYTE n) |
|
|
566 |
.................... { |
|
|
567 |
.................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7)) |
|
|
568 |
.................... /* Write to the data port */ |
|
|
569 |
.................... output_bit(LCD_DATA4, bit_test(n, 0)); |
|
|
570 |
* |
3286 |
kaklik |
571 |
010F: BTFSC 52.0 |
3283 |
kakl |
572 |
0110: GOTO 113 |
|
|
573 |
0111: BCF 08.4 |
|
|
574 |
0112: GOTO 114 |
|
|
575 |
0113: BSF 08.4 |
|
|
576 |
0114: BSF 03.5 |
|
|
577 |
0115: BCF 08.4 |
3275 |
kaklik |
578 |
.................... output_bit(LCD_DATA5, bit_test(n, 1)); |
3283 |
kakl |
579 |
0116: BCF 03.5 |
3286 |
kaklik |
580 |
0117: BTFSC 52.1 |
3283 |
kakl |
581 |
0118: GOTO 11B |
|
|
582 |
0119: BCF 08.5 |
|
|
583 |
011A: GOTO 11C |
|
|
584 |
011B: BSF 08.5 |
|
|
585 |
011C: BSF 03.5 |
|
|
586 |
011D: BCF 08.5 |
3275 |
kaklik |
587 |
.................... output_bit(LCD_DATA6, bit_test(n, 2)); |
3283 |
kakl |
588 |
011E: BCF 03.5 |
3286 |
kaklik |
589 |
011F: BTFSC 52.2 |
3283 |
kakl |
590 |
0120: GOTO 123 |
|
|
591 |
0121: BCF 08.6 |
|
|
592 |
0122: GOTO 124 |
|
|
593 |
0123: BSF 08.6 |
|
|
594 |
0124: BSF 03.5 |
|
|
595 |
0125: BCF 08.6 |
3275 |
kaklik |
596 |
.................... output_bit(LCD_DATA7, bit_test(n, 3)); |
3283 |
kakl |
597 |
0126: BCF 03.5 |
3286 |
kaklik |
598 |
0127: BTFSC 52.3 |
3283 |
kakl |
599 |
0128: GOTO 12B |
|
|
600 |
0129: BCF 08.7 |
|
|
601 |
012A: GOTO 12C |
|
|
602 |
012B: BSF 08.7 |
|
|
603 |
012C: BSF 03.5 |
|
|
604 |
012D: BCF 08.7 |
3275 |
kaklik |
605 |
.................... #else |
|
|
606 |
.................... lcdlat.data = n; |
|
|
607 |
.................... #endif |
|
|
608 |
.................... |
|
|
609 |
.................... delay_cycles(1); |
3283 |
kakl |
610 |
012E: NOP |
3275 |
kaklik |
611 |
.................... lcd_output_enable(1); |
3283 |
kakl |
612 |
012F: BCF 03.5 |
|
|
613 |
0130: BSF 09.0 |
|
|
614 |
0131: BSF 03.5 |
|
|
615 |
0132: BCF 09.0 |
3275 |
kaklik |
616 |
.................... delay_us(2); |
3283 |
kakl |
617 |
0133: GOTO 134 |
|
|
618 |
0134: GOTO 135 |
3275 |
kaklik |
619 |
.................... lcd_output_enable(0); |
3283 |
kakl |
620 |
0135: BCF 03.5 |
|
|
621 |
0136: BCF 09.0 |
|
|
622 |
0137: BSF 03.5 |
|
|
623 |
0138: BCF 09.0 |
3275 |
kaklik |
624 |
.................... } |
3283 |
kakl |
625 |
0139: BCF 03.5 |
|
|
626 |
013A: RETURN |
3275 |
kaklik |
627 |
.................... |
|
|
628 |
.................... void lcd_send_byte(BYTE address, BYTE n) |
|
|
629 |
.................... { |
|
|
630 |
.................... #if defined(__PCB__) |
|
|
631 |
.................... set_tris_lcd(LCD_OUTPUT_MAP); |
|
|
632 |
.................... #else |
|
|
633 |
.................... lcd_enable_tris(); |
|
|
634 |
* |
3283 |
kakl |
635 |
016C: BSF 03.5 |
|
|
636 |
016D: BCF 09.0 |
3275 |
kaklik |
637 |
.................... lcd_rs_tris(); |
3283 |
kakl |
638 |
016E: BCF 09.1 |
3275 |
kaklik |
639 |
.................... lcd_rw_tris(); |
3283 |
kakl |
640 |
016F: BCF 09.2 |
3275 |
kaklik |
641 |
.................... #endif |
|
|
642 |
.................... |
|
|
643 |
.................... lcd_output_rs(0); |
3283 |
kakl |
644 |
0170: BCF 03.5 |
|
|
645 |
0171: BCF 09.1 |
|
|
646 |
0172: BSF 03.5 |
|
|
647 |
0173: BCF 09.1 |
3275 |
kaklik |
648 |
.................... while ( bit_test(lcd_read_byte(),7) ) ; |
|
|
649 |
* |
3283 |
kakl |
650 |
01A2: MOVF 78,W |
3286 |
kaklik |
651 |
01A3: MOVWF 51 |
|
|
652 |
01A4: BTFSS 51.7 |
3283 |
kakl |
653 |
01A5: GOTO 1A8 |
|
|
654 |
01A6: BSF 03.5 |
|
|
655 |
01A7: GOTO 174 |
3275 |
kaklik |
656 |
.................... lcd_output_rs(address); |
3286 |
kaklik |
657 |
01A8: MOVF 4F,F |
3283 |
kakl |
658 |
01A9: BTFSS 03.2 |
|
|
659 |
01AA: GOTO 1AD |
|
|
660 |
01AB: BCF 09.1 |
|
|
661 |
01AC: GOTO 1AE |
|
|
662 |
01AD: BSF 09.1 |
|
|
663 |
01AE: BSF 03.5 |
|
|
664 |
01AF: BCF 09.1 |
3275 |
kaklik |
665 |
.................... delay_cycles(1); |
3283 |
kakl |
666 |
01B0: NOP |
3275 |
kaklik |
667 |
.................... lcd_output_rw(0); |
3283 |
kakl |
668 |
01B1: BCF 03.5 |
|
|
669 |
01B2: BCF 09.2 |
|
|
670 |
01B3: BSF 03.5 |
|
|
671 |
01B4: BCF 09.2 |
3275 |
kaklik |
672 |
.................... delay_cycles(1); |
3283 |
kakl |
673 |
01B5: NOP |
3275 |
kaklik |
674 |
.................... lcd_output_enable(0); |
3283 |
kakl |
675 |
01B6: BCF 03.5 |
|
|
676 |
01B7: BCF 09.0 |
|
|
677 |
01B8: BSF 03.5 |
|
|
678 |
01B9: BCF 09.0 |
3275 |
kaklik |
679 |
.................... lcd_send_nibble(n >> 4); |
3283 |
kakl |
680 |
01BA: BCF 03.5 |
3286 |
kaklik |
681 |
01BB: SWAPF 50,W |
|
|
682 |
01BC: MOVWF 51 |
3283 |
kakl |
683 |
01BD: MOVLW 0F |
3286 |
kaklik |
684 |
01BE: ANDWF 51,F |
|
|
685 |
01BF: MOVF 51,W |
|
|
686 |
01C0: MOVWF 52 |
3283 |
kakl |
687 |
01C1: CALL 10F |
3275 |
kaklik |
688 |
.................... lcd_send_nibble(n & 0xf); |
3286 |
kaklik |
689 |
01C2: MOVF 50,W |
3283 |
kakl |
690 |
01C3: ANDLW 0F |
3286 |
kaklik |
691 |
01C4: MOVWF 51 |
|
|
692 |
01C5: MOVWF 52 |
3283 |
kakl |
693 |
01C6: CALL 10F |
3275 |
kaklik |
694 |
.................... } |
3283 |
kakl |
695 |
01C7: RETURN |
3275 |
kaklik |
696 |
.................... |
|
|
697 |
.................... #if defined(LCD_EXTENDED_NEWLINE) |
|
|
698 |
.................... unsigned int8 g_LcdX, g_LcdY; |
|
|
699 |
.................... #endif |
|
|
700 |
.................... |
|
|
701 |
.................... void lcd_init(void) |
|
|
702 |
.................... { |
|
|
703 |
.................... BYTE i; |
|
|
704 |
.................... |
|
|
705 |
.................... #if defined(__PCB__) |
|
|
706 |
.................... set_tris_lcd(LCD_OUTPUT_MAP); |
|
|
707 |
.................... #else |
|
|
708 |
.................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7)) |
|
|
709 |
.................... output_drive(LCD_DATA4); |
3283 |
kakl |
710 |
01C8: BSF 03.5 |
|
|
711 |
01C9: BCF 08.4 |
3275 |
kaklik |
712 |
.................... output_drive(LCD_DATA5); |
3283 |
kakl |
713 |
01CA: BCF 08.5 |
3275 |
kaklik |
714 |
.................... output_drive(LCD_DATA6); |
3283 |
kakl |
715 |
01CB: BCF 08.6 |
3275 |
kaklik |
716 |
.................... output_drive(LCD_DATA7); |
3283 |
kakl |
717 |
01CC: BCF 08.7 |
3275 |
kaklik |
718 |
.................... #else |
|
|
719 |
.................... lcdtris.data = 0x0; |
|
|
720 |
.................... #endif |
|
|
721 |
.................... lcd_enable_tris(); |
3283 |
kakl |
722 |
01CD: BCF 09.0 |
3275 |
kaklik |
723 |
.................... lcd_rs_tris(); |
3283 |
kakl |
724 |
01CE: BCF 09.1 |
3275 |
kaklik |
725 |
.................... lcd_rw_tris(); |
3283 |
kakl |
726 |
01CF: BCF 09.2 |
3275 |
kaklik |
727 |
.................... #endif |
|
|
728 |
.................... |
|
|
729 |
.................... lcd_output_rs(0); |
3283 |
kakl |
730 |
01D0: BCF 03.5 |
|
|
731 |
01D1: BCF 09.1 |
|
|
732 |
01D2: BSF 03.5 |
|
|
733 |
01D3: BCF 09.1 |
3275 |
kaklik |
734 |
.................... lcd_output_rw(0); |
3283 |
kakl |
735 |
01D4: BCF 03.5 |
|
|
736 |
01D5: BCF 09.2 |
|
|
737 |
01D6: BSF 03.5 |
|
|
738 |
01D7: BCF 09.2 |
3275 |
kaklik |
739 |
.................... lcd_output_enable(0); |
3283 |
kakl |
740 |
01D8: BCF 03.5 |
|
|
741 |
01D9: BCF 09.0 |
|
|
742 |
01DA: BSF 03.5 |
|
|
743 |
01DB: BCF 09.0 |
3275 |
kaklik |
744 |
.................... |
|
|
745 |
.................... delay_ms(15); |
3283 |
kakl |
746 |
01DC: MOVLW 0F |
|
|
747 |
01DD: BCF 03.5 |
3286 |
kaklik |
748 |
01DE: MOVWF 4B |
3283 |
kakl |
749 |
01DF: CALL 0FB |
3275 |
kaklik |
750 |
.................... for(i=1;i<=3;++i) |
3283 |
kakl |
751 |
01E0: MOVLW 01 |
3286 |
kaklik |
752 |
01E1: MOVWF 3D |
|
|
753 |
01E2: MOVF 3D,W |
3283 |
kakl |
754 |
01E3: SUBLW 03 |
|
|
755 |
01E4: BTFSS 03.0 |
|
|
756 |
01E5: GOTO 1EE |
3275 |
kaklik |
757 |
.................... { |
|
|
758 |
.................... lcd_send_nibble(3); |
3283 |
kakl |
759 |
01E6: MOVLW 03 |
3286 |
kaklik |
760 |
01E7: MOVWF 52 |
3283 |
kakl |
761 |
01E8: CALL 10F |
3275 |
kaklik |
762 |
.................... delay_ms(5); |
3283 |
kakl |
763 |
01E9: MOVLW 05 |
3286 |
kaklik |
764 |
01EA: MOVWF 4B |
3283 |
kakl |
765 |
01EB: CALL 0FB |
3275 |
kaklik |
766 |
.................... } |
3286 |
kaklik |
767 |
01EC: INCF 3D,F |
3283 |
kakl |
768 |
01ED: GOTO 1E2 |
3275 |
kaklik |
769 |
.................... |
|
|
770 |
.................... lcd_send_nibble(2); |
3283 |
kakl |
771 |
01EE: MOVLW 02 |
3286 |
kaklik |
772 |
01EF: MOVWF 52 |
3283 |
kakl |
773 |
01F0: CALL 10F |
3275 |
kaklik |
774 |
.................... for(i=0;i<=3;++i) |
3286 |
kaklik |
775 |
01F1: CLRF 3D |
|
|
776 |
01F2: MOVF 3D,W |
3283 |
kakl |
777 |
01F3: SUBLW 03 |
|
|
778 |
01F4: BTFSS 03.0 |
|
|
779 |
01F5: GOTO 1FF |
3275 |
kaklik |
780 |
.................... lcd_send_byte(0,LCD_INIT_STRING[i]); |
3286 |
kaklik |
781 |
01F6: MOVF 3D,W |
3283 |
kakl |
782 |
01F7: CALL 004 |
3286 |
kaklik |
783 |
01F8: MOVWF 3E |
|
|
784 |
01F9: CLRF 4F |
|
|
785 |
01FA: MOVF 3E,W |
|
|
786 |
01FB: MOVWF 50 |
3283 |
kakl |
787 |
01FC: CALL 16C |
3275 |
kaklik |
788 |
.................... |
|
|
789 |
.................... #if defined(LCD_EXTENDED_NEWLINE) |
3286 |
kaklik |
790 |
01FD: INCF 3D,F |
3283 |
kakl |
791 |
01FE: GOTO 1F2 |
3275 |
kaklik |
792 |
.................... g_LcdX = 0; |
|
|
793 |
.................... g_LcdY = 0; |
|
|
794 |
.................... #endif |
|
|
795 |
.................... } |
3283 |
kakl |
796 |
01FF: RETURN |
3275 |
kaklik |
797 |
.................... |
|
|
798 |
.................... void lcd_gotoxy(BYTE x, BYTE y) |
|
|
799 |
.................... { |
|
|
800 |
.................... BYTE address; |
|
|
801 |
.................... |
|
|
802 |
.................... if(y!=1) |
3286 |
kaklik |
803 |
0200: DECFSZ 4C,W |
3283 |
kakl |
804 |
0201: GOTO 203 |
|
|
805 |
0202: GOTO 206 |
3275 |
kaklik |
806 |
.................... address=LCD_LINE_TWO; |
3283 |
kakl |
807 |
0203: MOVLW 40 |
3286 |
kaklik |
808 |
0204: MOVWF 4D |
3275 |
kaklik |
809 |
.................... else |
3283 |
kakl |
810 |
0205: GOTO 207 |
3275 |
kaklik |
811 |
.................... address=0; |
3286 |
kaklik |
812 |
0206: CLRF 4D |
3275 |
kaklik |
813 |
.................... |
|
|
814 |
.................... address+=x-1; |
3283 |
kakl |
815 |
0207: MOVLW 01 |
3286 |
kaklik |
816 |
0208: SUBWF 4B,W |
|
|
817 |
0209: ADDWF 4D,F |
3275 |
kaklik |
818 |
.................... lcd_send_byte(0,0x80|address); |
3286 |
kaklik |
819 |
020A: MOVF 4D,W |
3283 |
kakl |
820 |
020B: IORLW 80 |
3286 |
kaklik |
821 |
020C: MOVWF 4E |
|
|
822 |
020D: CLRF 4F |
|
|
823 |
020E: MOVF 4E,W |
|
|
824 |
020F: MOVWF 50 |
3283 |
kakl |
825 |
0210: CALL 16C |
3275 |
kaklik |
826 |
.................... |
|
|
827 |
.................... #if defined(LCD_EXTENDED_NEWLINE) |
|
|
828 |
.................... g_LcdX = x - 1; |
|
|
829 |
.................... g_LcdY = y - 1; |
|
|
830 |
.................... #endif |
|
|
831 |
.................... } |
3283 |
kakl |
832 |
0211: RETURN |
3275 |
kaklik |
833 |
.................... |
|
|
834 |
.................... void lcd_putc(char c) |
|
|
835 |
.................... { |
|
|
836 |
.................... switch (c) |
|
|
837 |
.................... { |
3286 |
kaklik |
838 |
0212: MOVF 4A,W |
3283 |
kakl |
839 |
0213: XORLW 07 |
|
|
840 |
0214: BTFSC 03.2 |
|
|
841 |
0215: GOTO 220 |
|
|
842 |
0216: XORLW 0B |
|
|
843 |
0217: BTFSC 03.2 |
|
|
844 |
0218: GOTO 225 |
|
|
845 |
0219: XORLW 06 |
|
|
846 |
021A: BTFSC 03.2 |
|
|
847 |
021B: GOTO 22D |
|
|
848 |
021C: XORLW 02 |
|
|
849 |
021D: BTFSC 03.2 |
|
|
850 |
021E: GOTO 233 |
|
|
851 |
021F: GOTO 238 |
3275 |
kaklik |
852 |
.................... case '\a' : lcd_gotoxy(1,1); break; |
3283 |
kakl |
853 |
0220: MOVLW 01 |
3286 |
kaklik |
854 |
0221: MOVWF 4B |
|
|
855 |
0222: MOVWF 4C |
3283 |
kakl |
856 |
0223: CALL 200 |
|
|
857 |
0224: GOTO 23E |
3275 |
kaklik |
858 |
.................... |
|
|
859 |
.................... case '\f' : lcd_send_byte(0,1); |
3286 |
kaklik |
860 |
0225: CLRF 4F |
3283 |
kakl |
861 |
0226: MOVLW 01 |
3286 |
kaklik |
862 |
0227: MOVWF 50 |
3283 |
kakl |
863 |
0228: CALL 16C |
3275 |
kaklik |
864 |
.................... delay_ms(2); |
3283 |
kakl |
865 |
0229: MOVLW 02 |
3286 |
kaklik |
866 |
022A: MOVWF 4B |
3283 |
kakl |
867 |
022B: CALL 0FB |
3275 |
kaklik |
868 |
.................... #if defined(LCD_EXTENDED_NEWLINE) |
|
|
869 |
.................... g_LcdX = 0; |
|
|
870 |
.................... g_LcdY = 0; |
|
|
871 |
.................... #endif |
|
|
872 |
.................... break; |
3283 |
kakl |
873 |
022C: GOTO 23E |
3275 |
kaklik |
874 |
.................... |
|
|
875 |
.................... #if defined(LCD_EXTENDED_NEWLINE) |
|
|
876 |
.................... case '\r' : lcd_gotoxy(1, g_LcdY+1); break; |
|
|
877 |
.................... case '\n' : |
|
|
878 |
.................... while (g_LcdX++ < LCD_LINE_LENGTH) |
|
|
879 |
.................... { |
|
|
880 |
.................... lcd_send_byte(1, ' '); |
|
|
881 |
.................... } |
|
|
882 |
.................... lcd_gotoxy(1, g_LcdY+2); |
|
|
883 |
.................... break; |
|
|
884 |
.................... #else |
|
|
885 |
.................... case '\n' : lcd_gotoxy(1,2); break; |
3283 |
kakl |
886 |
022D: MOVLW 01 |
3286 |
kaklik |
887 |
022E: MOVWF 4B |
3283 |
kakl |
888 |
022F: MOVLW 02 |
3286 |
kaklik |
889 |
0230: MOVWF 4C |
3283 |
kakl |
890 |
0231: CALL 200 |
|
|
891 |
0232: GOTO 23E |
3275 |
kaklik |
892 |
.................... #endif |
|
|
893 |
.................... |
|
|
894 |
.................... case '\b' : lcd_send_byte(0,0x10); break; |
3286 |
kaklik |
895 |
0233: CLRF 4F |
3283 |
kakl |
896 |
0234: MOVLW 10 |
3286 |
kaklik |
897 |
0235: MOVWF 50 |
3283 |
kakl |
898 |
0236: CALL 16C |
|
|
899 |
0237: GOTO 23E |
3275 |
kaklik |
900 |
.................... |
|
|
901 |
.................... #if defined(LCD_EXTENDED_NEWLINE) |
|
|
902 |
.................... default : |
|
|
903 |
.................... if (g_LcdX < LCD_LINE_LENGTH) |
|
|
904 |
.................... { |
|
|
905 |
.................... lcd_send_byte(1, c); |
|
|
906 |
.................... g_LcdX++; |
|
|
907 |
.................... } |
|
|
908 |
.................... break; |
|
|
909 |
.................... #else |
|
|
910 |
.................... default : lcd_send_byte(1,c); break; |
3283 |
kakl |
911 |
0238: MOVLW 01 |
3286 |
kaklik |
912 |
0239: MOVWF 4F |
|
|
913 |
023A: MOVF 4A,W |
|
|
914 |
023B: MOVWF 50 |
3283 |
kakl |
915 |
023C: CALL 16C |
|
|
916 |
023D: GOTO 23E |
3275 |
kaklik |
917 |
.................... #endif |
|
|
918 |
.................... } |
|
|
919 |
.................... } |
3283 |
kakl |
920 |
023E: RETURN |
3275 |
kaklik |
921 |
.................... |
|
|
922 |
.................... char lcd_getc(BYTE x, BYTE y) |
|
|
923 |
.................... { |
|
|
924 |
.................... char value; |
|
|
925 |
.................... |
|
|
926 |
.................... lcd_gotoxy(x,y); |
|
|
927 |
.................... while ( bit_test(lcd_read_byte(),7) ); // wait until busy flag is low |
|
|
928 |
.................... lcd_output_rs(1); |
|
|
929 |
.................... value = lcd_read_byte(); |
|
|
930 |
.................... lcd_output_rs(0); |
|
|
931 |
.................... |
|
|
932 |
.................... return(value); |
|
|
933 |
.................... } |
|
|
934 |
.................... |
|
|
935 |
.................... |
|
|
936 |
.................... #include "../SHT25.h" |
|
|
937 |
.................... |
|
|
938 |
.................... #define SHT25_HEATER_ON 0x04 |
|
|
939 |
.................... #define SHT25_HEATER_OFF 0x00 |
|
|
940 |
.................... #define SHT25_OTP_reload_off 0x02 |
|
|
941 |
.................... #define SHT25_RH12_T14 0x00 |
|
|
942 |
.................... #define SHT25_RH8_T12 0x01 |
|
|
943 |
.................... #define SHT25_RH10_T13 0x80 |
|
|
944 |
.................... #define SHT25_RH11_T11 0x81 |
|
|
945 |
.................... |
|
|
946 |
.................... #define SHT25_ADDR 0x80 |
|
|
947 |
.................... |
|
|
948 |
.................... #include "SHT25.c" |
|
|
949 |
.................... void SHT25_soft_reset() |
|
|
950 |
.................... { |
|
|
951 |
.................... i2c_start(); // Start condition |
|
|
952 |
.................... i2c_write(0x80); // Device address |
|
|
953 |
.................... i2c_write(0xFE); // Device command |
|
|
954 |
.................... i2c_stop(); // Stop condition |
|
|
955 |
.................... } |
|
|
956 |
.................... |
|
|
957 |
.................... unsigned int8 SHT25_setup(unsigned int8 setup_reg ) // writes to status register and returns its value |
|
|
958 |
.................... { |
|
|
959 |
.................... unsigned int8 reg; |
|
|
960 |
.................... |
|
|
961 |
.................... i2c_start(); // Start condition |
|
|
962 |
.................... i2c_write(SHT25_ADDR); // Device address |
|
|
963 |
.................... i2c_write(0xE7); // Device command |
|
|
964 |
.................... |
|
|
965 |
.................... i2c_start(); // Start condition |
|
|
966 |
.................... i2c_write(SHT25_ADDR+1); // Device address |
|
|
967 |
.................... reg=i2c_read(0); // Read status actual status register |
|
|
968 |
.................... |
|
|
969 |
.................... reg = (reg & 0x3A) | setup_reg; |
|
|
970 |
.................... |
|
|
971 |
.................... i2c_start(); // Start condition |
|
|
972 |
.................... i2c_write(SHT25_ADDR); // Device address |
|
|
973 |
.................... i2c_write(0xE6); // Write to status register |
|
|
974 |
.................... i2c_write(reg); // Device command |
|
|
975 |
.................... i2c_stop(); // Stop condition |
|
|
976 |
.................... |
|
|
977 |
.................... delay_ms(10); |
|
|
978 |
.................... |
|
|
979 |
.................... i2c_start(); // Start condition |
|
|
980 |
.................... i2c_write(SHT25_ADDR); // Device address |
|
|
981 |
.................... i2c_write(0xE7); // Device command |
|
|
982 |
.................... |
|
|
983 |
.................... i2c_start(); // Start condition |
|
|
984 |
.................... i2c_write(SHT25_ADDR+1); // Device address |
|
|
985 |
.................... reg=i2c_read(0); // Read status actual status register |
|
|
986 |
.................... |
|
|
987 |
.................... return (reg); |
|
|
988 |
.................... } |
|
|
989 |
.................... |
|
|
990 |
.................... |
|
|
991 |
.................... float SHT25_get_temp() |
|
|
992 |
.................... { |
|
|
993 |
.................... unsigned int8 MSB, LSB, Check; |
|
|
994 |
.................... unsigned int16 data; |
|
|
995 |
.................... |
|
|
996 |
.................... i2c_start(); |
|
|
997 |
* |
3283 |
kakl |
998 |
0567: BSF 20.4 |
|
|
999 |
0568: MOVF 20,W |
|
|
1000 |
0569: BSF 03.5 |
|
|
1001 |
056A: MOVWF 07 |
|
|
1002 |
056B: NOP |
|
|
1003 |
056C: BCF 03.5 |
|
|
1004 |
056D: BSF 20.3 |
|
|
1005 |
056E: MOVF 20,W |
|
|
1006 |
056F: BSF 03.5 |
|
|
1007 |
0570: MOVWF 07 |
|
|
1008 |
0571: NOP |
|
|
1009 |
0572: BCF 03.5 |
|
|
1010 |
0573: BTFSS 07.3 |
|
|
1011 |
0574: GOTO 573 |
|
|
1012 |
0575: BCF 07.4 |
|
|
1013 |
0576: BCF 20.4 |
|
|
1014 |
0577: MOVF 20,W |
|
|
1015 |
0578: BSF 03.5 |
|
|
1016 |
0579: MOVWF 07 |
|
|
1017 |
057A: NOP |
|
|
1018 |
057B: BCF 03.5 |
|
|
1019 |
057C: BCF 07.3 |
|
|
1020 |
057D: BCF 20.3 |
|
|
1021 |
057E: MOVF 20,W |
|
|
1022 |
057F: BSF 03.5 |
|
|
1023 |
0580: MOVWF 07 |
3275 |
kaklik |
1024 |
.................... I2C_Write(SHT25_ADDR); |
3283 |
kakl |
1025 |
0581: MOVLW 80 |
|
|
1026 |
0582: BCF 03.5 |
3286 |
kaklik |
1027 |
0583: MOVWF 4E |
3283 |
kakl |
1028 |
0584: CALL 078 |
3275 |
kaklik |
1029 |
.................... I2C_write(0xE3); |
3283 |
kakl |
1030 |
0585: MOVLW E3 |
3286 |
kaklik |
1031 |
0586: MOVWF 4E |
3283 |
kakl |
1032 |
0587: CALL 078 |
3275 |
kaklik |
1033 |
.................... i2c_stop(); |
3283 |
kakl |
1034 |
0588: BCF 20.4 |
|
|
1035 |
0589: MOVF 20,W |
|
|
1036 |
058A: BSF 03.5 |
|
|
1037 |
058B: MOVWF 07 |
|
|
1038 |
058C: NOP |
|
|
1039 |
058D: BCF 03.5 |
|
|
1040 |
058E: BSF 20.3 |
|
|
1041 |
058F: MOVF 20,W |
|
|
1042 |
0590: BSF 03.5 |
|
|
1043 |
0591: MOVWF 07 |
|
|
1044 |
0592: BCF 03.5 |
|
|
1045 |
0593: BTFSS 07.3 |
|
|
1046 |
0594: GOTO 593 |
|
|
1047 |
0595: NOP |
|
|
1048 |
0596: GOTO 597 |
|
|
1049 |
0597: NOP |
|
|
1050 |
0598: BSF 20.4 |
|
|
1051 |
0599: MOVF 20,W |
|
|
1052 |
059A: BSF 03.5 |
|
|
1053 |
059B: MOVWF 07 |
|
|
1054 |
059C: NOP |
3275 |
kaklik |
1055 |
.................... |
|
|
1056 |
.................... delay_ms(100); |
3283 |
kakl |
1057 |
059D: MOVLW 64 |
|
|
1058 |
059E: BCF 03.5 |
3286 |
kaklik |
1059 |
059F: MOVWF 4B |
3283 |
kakl |
1060 |
05A0: CALL 0FB |
3275 |
kaklik |
1061 |
.................... |
|
|
1062 |
.................... i2c_start(); |
3283 |
kakl |
1063 |
05A1: BSF 20.4 |
|
|
1064 |
05A2: MOVF 20,W |
|
|
1065 |
05A3: BSF 03.5 |
|
|
1066 |
05A4: MOVWF 07 |
|
|
1067 |
05A5: NOP |
|
|
1068 |
05A6: BCF 03.5 |
|
|
1069 |
05A7: BSF 20.3 |
|
|
1070 |
05A8: MOVF 20,W |
|
|
1071 |
05A9: BSF 03.5 |
|
|
1072 |
05AA: MOVWF 07 |
|
|
1073 |
05AB: NOP |
|
|
1074 |
05AC: BCF 03.5 |
|
|
1075 |
05AD: BCF 07.4 |
|
|
1076 |
05AE: BCF 20.4 |
|
|
1077 |
05AF: MOVF 20,W |
|
|
1078 |
05B0: BSF 03.5 |
|
|
1079 |
05B1: MOVWF 07 |
|
|
1080 |
05B2: NOP |
|
|
1081 |
05B3: BCF 03.5 |
|
|
1082 |
05B4: BCF 07.3 |
|
|
1083 |
05B5: BCF 20.3 |
|
|
1084 |
05B6: MOVF 20,W |
|
|
1085 |
05B7: BSF 03.5 |
|
|
1086 |
05B8: MOVWF 07 |
3275 |
kaklik |
1087 |
.................... I2C_Write(SHT25_ADDR+1); |
3283 |
kakl |
1088 |
05B9: MOVLW 81 |
|
|
1089 |
05BA: BCF 03.5 |
3286 |
kaklik |
1090 |
05BB: MOVWF 4E |
3283 |
kakl |
1091 |
05BC: CALL 078 |
3275 |
kaklik |
1092 |
.................... MSB=i2c_read(1); |
3283 |
kakl |
1093 |
05BD: MOVLW 01 |
|
|
1094 |
05BE: MOVWF 77 |
|
|
1095 |
05BF: CALL 285 |
|
|
1096 |
05C0: MOVF 78,W |
3286 |
kaklik |
1097 |
05C1: MOVWF 3D |
3275 |
kaklik |
1098 |
.................... LSB=i2c_read(1); |
3283 |
kakl |
1099 |
05C2: MOVLW 01 |
|
|
1100 |
05C3: MOVWF 77 |
|
|
1101 |
05C4: CALL 285 |
|
|
1102 |
05C5: MOVF 78,W |
3286 |
kaklik |
1103 |
05C6: MOVWF 3E |
3275 |
kaklik |
1104 |
.................... Check=i2c_read(0); |
3283 |
kakl |
1105 |
05C7: CLRF 77 |
|
|
1106 |
05C8: CALL 285 |
|
|
1107 |
05C9: MOVF 78,W |
3286 |
kaklik |
1108 |
05CA: MOVWF 3F |
3275 |
kaklik |
1109 |
.................... i2c_stop(); |
3283 |
kakl |
1110 |
05CB: BCF 20.4 |
|
|
1111 |
05CC: MOVF 20,W |
|
|
1112 |
05CD: BSF 03.5 |
|
|
1113 |
05CE: MOVWF 07 |
|
|
1114 |
05CF: NOP |
|
|
1115 |
05D0: BCF 03.5 |
|
|
1116 |
05D1: BSF 20.3 |
|
|
1117 |
05D2: MOVF 20,W |
|
|
1118 |
05D3: BSF 03.5 |
|
|
1119 |
05D4: MOVWF 07 |
|
|
1120 |
05D5: BCF 03.5 |
|
|
1121 |
05D6: BTFSS 07.3 |
|
|
1122 |
05D7: GOTO 5D6 |
|
|
1123 |
05D8: NOP |
|
|
1124 |
05D9: GOTO 5DA |
|
|
1125 |
05DA: NOP |
|
|
1126 |
05DB: BSF 20.4 |
|
|
1127 |
05DC: MOVF 20,W |
|
|
1128 |
05DD: BSF 03.5 |
|
|
1129 |
05DE: MOVWF 07 |
|
|
1130 |
05DF: NOP |
3275 |
kaklik |
1131 |
.................... |
|
|
1132 |
.................... LSB = LSB >> 2; // trow out status bits |
3283 |
kakl |
1133 |
05E0: BCF 03.5 |
3286 |
kaklik |
1134 |
05E1: RRF 3E,F |
|
|
1135 |
05E2: RRF 3E,F |
3283 |
kakl |
1136 |
05E3: MOVLW 3F |
3286 |
kaklik |
1137 |
05E4: ANDWF 3E,F |
3275 |
kaklik |
1138 |
.................... |
|
|
1139 |
.................... data = (((unsigned int16) MSB << 8) + (LSB << 4)); |
3286 |
kaklik |
1140 |
05E5: CLRF 43 |
|
|
1141 |
05E6: MOVF 3D,W |
|
|
1142 |
05E7: MOVWF 42 |
|
|
1143 |
05E8: MOVWF 43 |
|
|
1144 |
05E9: CLRF 42 |
|
|
1145 |
05EA: SWAPF 3E,W |
3283 |
kakl |
1146 |
05EB: MOVWF 77 |
|
|
1147 |
05EC: MOVLW F0 |
|
|
1148 |
05ED: ANDWF 77,F |
|
|
1149 |
05EE: MOVF 77,W |
3286 |
kaklik |
1150 |
05EF: ADDWF 42,W |
|
|
1151 |
05F0: MOVWF 40 |
|
|
1152 |
05F1: MOVF 43,W |
|
|
1153 |
05F2: MOVWF 41 |
3283 |
kakl |
1154 |
05F3: BTFSC 03.0 |
3286 |
kaklik |
1155 |
05F4: INCF 41,F |
3275 |
kaklik |
1156 |
.................... return(-46.85 + 175.72*((float)data/0xFFFF)); |
3286 |
kaklik |
1157 |
05F5: MOVF 41,W |
|
|
1158 |
05F6: MOVWF 4E |
|
|
1159 |
05F7: MOVF 40,W |
|
|
1160 |
05F8: MOVWF 4D |
3283 |
kakl |
1161 |
05F9: CALL 2CA |
|
|
1162 |
05FA: MOVF 77,W |
3286 |
kaklik |
1163 |
05FB: MOVWF 42 |
3283 |
kakl |
1164 |
05FC: MOVF 78,W |
3286 |
kaklik |
1165 |
05FD: MOVWF 43 |
3283 |
kakl |
1166 |
05FE: MOVF 79,W |
3286 |
kaklik |
1167 |
05FF: MOVWF 44 |
3283 |
kakl |
1168 |
0600: MOVF 7A,W |
3286 |
kaklik |
1169 |
0601: MOVWF 45 |
|
|
1170 |
0602: MOVWF 54 |
3283 |
kakl |
1171 |
0603: MOVF 79,W |
3286 |
kaklik |
1172 |
0604: MOVWF 53 |
3283 |
kakl |
1173 |
0605: MOVF 78,W |
3286 |
kaklik |
1174 |
0606: MOVWF 52 |
3283 |
kakl |
1175 |
0607: MOVF 77,W |
3286 |
kaklik |
1176 |
0608: MOVWF 51 |
|
|
1177 |
0609: CLRF 58 |
3283 |
kakl |
1178 |
060A: MOVLW FF |
3286 |
kaklik |
1179 |
060B: MOVWF 57 |
3283 |
kakl |
1180 |
060C: MOVLW 7F |
3286 |
kaklik |
1181 |
060D: MOVWF 56 |
3283 |
kakl |
1182 |
060E: MOVLW 8E |
3286 |
kaklik |
1183 |
060F: MOVWF 55 |
3283 |
kakl |
1184 |
0610: CALL 2E7 |
|
|
1185 |
0611: MOVLW 52 |
3286 |
kaklik |
1186 |
0612: MOVWF 4D |
3283 |
kakl |
1187 |
0613: MOVLW B8 |
3286 |
kaklik |
1188 |
0614: MOVWF 4C |
3283 |
kakl |
1189 |
0615: MOVLW 2F |
3286 |
kaklik |
1190 |
0616: MOVWF 4B |
3283 |
kakl |
1191 |
0617: MOVLW 86 |
3286 |
kaklik |
1192 |
0618: MOVWF 4A |
3283 |
kakl |
1193 |
0619: MOVF 7A,W |
3286 |
kaklik |
1194 |
061A: MOVWF 51 |
3283 |
kakl |
1195 |
061B: MOVF 79,W |
3286 |
kaklik |
1196 |
061C: MOVWF 50 |
3283 |
kakl |
1197 |
061D: MOVF 78,W |
3286 |
kaklik |
1198 |
061E: MOVWF 4F |
3283 |
kakl |
1199 |
061F: MOVF 77,W |
3286 |
kaklik |
1200 |
0620: MOVWF 4E |
3283 |
kakl |
1201 |
0621: CALL 3B1 |
|
|
1202 |
0622: BCF 03.1 |
|
|
1203 |
0623: MOVLW 66 |
3286 |
kaklik |
1204 |
0624: MOVWF 56 |
|
|
1205 |
0625: MOVWF 55 |
3283 |
kakl |
1206 |
0626: MOVLW BB |
3286 |
kaklik |
1207 |
0627: MOVWF 54 |
3283 |
kakl |
1208 |
0628: MOVLW 84 |
3286 |
kaklik |
1209 |
0629: MOVWF 53 |
3283 |
kakl |
1210 |
062A: MOVF 7A,W |
3286 |
kaklik |
1211 |
062B: MOVWF 5A |
3283 |
kakl |
1212 |
062C: MOVF 79,W |
3286 |
kaklik |
1213 |
062D: MOVWF 59 |
3283 |
kakl |
1214 |
062E: MOVF 78,W |
3286 |
kaklik |
1215 |
062F: MOVWF 58 |
3283 |
kakl |
1216 |
0630: MOVF 77,W |
3286 |
kaklik |
1217 |
0631: MOVWF 57 |
3283 |
kakl |
1218 |
0632: CALL 426 |
3275 |
kaklik |
1219 |
.................... } |
3283 |
kakl |
1220 |
0633: BSF 0A.3 |
|
|
1221 |
0634: BCF 0A.4 |
3286 |
kaklik |
1222 |
0635: GOTO 5B9 (RETURN) |
3275 |
kaklik |
1223 |
.................... |
|
|
1224 |
.................... float SHT25_get_hum() |
|
|
1225 |
.................... { |
|
|
1226 |
.................... unsigned int8 MSB, LSB, Check; |
|
|
1227 |
.................... unsigned int16 data; |
|
|
1228 |
.................... |
|
|
1229 |
.................... i2c_start(); //RH |
3283 |
kakl |
1230 |
0636: BSF 20.4 |
|
|
1231 |
0637: MOVF 20,W |
|
|
1232 |
0638: BSF 03.5 |
|
|
1233 |
0639: MOVWF 07 |
|
|
1234 |
063A: NOP |
|
|
1235 |
063B: BCF 03.5 |
|
|
1236 |
063C: BSF 20.3 |
|
|
1237 |
063D: MOVF 20,W |
|
|
1238 |
063E: BSF 03.5 |
|
|
1239 |
063F: MOVWF 07 |
|
|
1240 |
0640: NOP |
|
|
1241 |
0641: BCF 03.5 |
|
|
1242 |
0642: BCF 07.4 |
|
|
1243 |
0643: BCF 20.4 |
|
|
1244 |
0644: MOVF 20,W |
|
|
1245 |
0645: BSF 03.5 |
|
|
1246 |
0646: MOVWF 07 |
|
|
1247 |
0647: NOP |
|
|
1248 |
0648: BCF 03.5 |
|
|
1249 |
0649: BCF 07.3 |
|
|
1250 |
064A: BCF 20.3 |
|
|
1251 |
064B: MOVF 20,W |
|
|
1252 |
064C: BSF 03.5 |
|
|
1253 |
064D: MOVWF 07 |
3275 |
kaklik |
1254 |
.................... I2C_Write(SHT25_ADDR); |
3283 |
kakl |
1255 |
064E: MOVLW 80 |
|
|
1256 |
064F: BCF 03.5 |
3286 |
kaklik |
1257 |
0650: MOVWF 4E |
3283 |
kakl |
1258 |
0651: CALL 078 |
3275 |
kaklik |
1259 |
.................... I2C_write(0xE5); |
3283 |
kakl |
1260 |
0652: MOVLW E5 |
3286 |
kaklik |
1261 |
0653: MOVWF 4E |
3283 |
kakl |
1262 |
0654: CALL 078 |
3275 |
kaklik |
1263 |
.................... |
|
|
1264 |
.................... delay_ms(100); |
3283 |
kakl |
1265 |
0655: MOVLW 64 |
3286 |
kaklik |
1266 |
0656: MOVWF 4B |
3283 |
kakl |
1267 |
0657: CALL 0FB |
3275 |
kaklik |
1268 |
.................... |
|
|
1269 |
.................... i2c_start(); |
3283 |
kakl |
1270 |
0658: BSF 20.4 |
|
|
1271 |
0659: MOVF 20,W |
|
|
1272 |
065A: BSF 03.5 |
|
|
1273 |
065B: MOVWF 07 |
|
|
1274 |
065C: NOP |
|
|
1275 |
065D: BCF 03.5 |
|
|
1276 |
065E: BSF 20.3 |
|
|
1277 |
065F: MOVF 20,W |
|
|
1278 |
0660: BSF 03.5 |
|
|
1279 |
0661: MOVWF 07 |
|
|
1280 |
0662: NOP |
|
|
1281 |
0663: BCF 03.5 |
|
|
1282 |
0664: BTFSS 07.3 |
|
|
1283 |
0665: GOTO 664 |
|
|
1284 |
0666: BCF 07.4 |
|
|
1285 |
0667: BCF 20.4 |
|
|
1286 |
0668: MOVF 20,W |
|
|
1287 |
0669: BSF 03.5 |
|
|
1288 |
066A: MOVWF 07 |
|
|
1289 |
066B: NOP |
|
|
1290 |
066C: BCF 03.5 |
|
|
1291 |
066D: BCF 07.3 |
|
|
1292 |
066E: BCF 20.3 |
|
|
1293 |
066F: MOVF 20,W |
|
|
1294 |
0670: BSF 03.5 |
|
|
1295 |
0671: MOVWF 07 |
3275 |
kaklik |
1296 |
.................... I2C_Write(SHT25_ADDR+1); |
3283 |
kakl |
1297 |
0672: MOVLW 81 |
|
|
1298 |
0673: BCF 03.5 |
3286 |
kaklik |
1299 |
0674: MOVWF 4E |
3283 |
kakl |
1300 |
0675: CALL 078 |
3275 |
kaklik |
1301 |
.................... MSB=i2c_read(1); |
3283 |
kakl |
1302 |
0676: MOVLW 01 |
|
|
1303 |
0677: MOVWF 77 |
|
|
1304 |
0678: CALL 285 |
|
|
1305 |
0679: MOVF 78,W |
3286 |
kaklik |
1306 |
067A: MOVWF 3D |
3275 |
kaklik |
1307 |
.................... LSB=i2c_read(1); |
3283 |
kakl |
1308 |
067B: MOVLW 01 |
|
|
1309 |
067C: MOVWF 77 |
|
|
1310 |
067D: CALL 285 |
|
|
1311 |
067E: MOVF 78,W |
3286 |
kaklik |
1312 |
067F: MOVWF 3E |
3275 |
kaklik |
1313 |
.................... Check=i2c_read(0); |
3283 |
kakl |
1314 |
0680: CLRF 77 |
|
|
1315 |
0681: CALL 285 |
|
|
1316 |
0682: MOVF 78,W |
3286 |
kaklik |
1317 |
0683: MOVWF 3F |
3275 |
kaklik |
1318 |
.................... i2c_stop(); |
3283 |
kakl |
1319 |
0684: BCF 20.4 |
|
|
1320 |
0685: MOVF 20,W |
|
|
1321 |
0686: BSF 03.5 |
|
|
1322 |
0687: MOVWF 07 |
|
|
1323 |
0688: NOP |
|
|
1324 |
0689: BCF 03.5 |
|
|
1325 |
068A: BSF 20.3 |
|
|
1326 |
068B: MOVF 20,W |
|
|
1327 |
068C: BSF 03.5 |
|
|
1328 |
068D: MOVWF 07 |
|
|
1329 |
068E: BCF 03.5 |
|
|
1330 |
068F: BTFSS 07.3 |
|
|
1331 |
0690: GOTO 68F |
|
|
1332 |
0691: NOP |
|
|
1333 |
0692: GOTO 693 |
|
|
1334 |
0693: NOP |
|
|
1335 |
0694: BSF 20.4 |
|
|
1336 |
0695: MOVF 20,W |
|
|
1337 |
0696: BSF 03.5 |
|
|
1338 |
0697: MOVWF 07 |
|
|
1339 |
0698: NOP |
3275 |
kaklik |
1340 |
.................... |
|
|
1341 |
.................... LSB = LSB >> 2; // trow out status bits |
3283 |
kakl |
1342 |
0699: BCF 03.5 |
3286 |
kaklik |
1343 |
069A: RRF 3E,F |
|
|
1344 |
069B: RRF 3E,F |
3283 |
kakl |
1345 |
069C: MOVLW 3F |
3286 |
kaklik |
1346 |
069D: ANDWF 3E,F |
3275 |
kaklik |
1347 |
.................... |
|
|
1348 |
.................... data = (((unsigned int16) MSB << 8) + (LSB << 4) ); |
3286 |
kaklik |
1349 |
069E: CLRF 43 |
|
|
1350 |
069F: MOVF 3D,W |
|
|
1351 |
06A0: MOVWF 42 |
|
|
1352 |
06A1: MOVWF 43 |
|
|
1353 |
06A2: CLRF 42 |
|
|
1354 |
06A3: SWAPF 3E,W |
3283 |
kakl |
1355 |
06A4: MOVWF 77 |
|
|
1356 |
06A5: MOVLW F0 |
|
|
1357 |
06A6: ANDWF 77,F |
|
|
1358 |
06A7: MOVF 77,W |
3286 |
kaklik |
1359 |
06A8: ADDWF 42,W |
|
|
1360 |
06A9: MOVWF 40 |
|
|
1361 |
06AA: MOVF 43,W |
|
|
1362 |
06AB: MOVWF 41 |
3283 |
kakl |
1363 |
06AC: BTFSC 03.0 |
3286 |
kaklik |
1364 |
06AD: INCF 41,F |
3275 |
kaklik |
1365 |
.................... return( -6.0 + 125.0*((float)data/0xFFFF)); |
3286 |
kaklik |
1366 |
06AE: MOVF 41,W |
|
|
1367 |
06AF: MOVWF 4E |
|
|
1368 |
06B0: MOVF 40,W |
|
|
1369 |
06B1: MOVWF 4D |
3283 |
kakl |
1370 |
06B2: CALL 2CA |
|
|
1371 |
06B3: MOVF 77,W |
3286 |
kaklik |
1372 |
06B4: MOVWF 42 |
3283 |
kakl |
1373 |
06B5: MOVF 78,W |
3286 |
kaklik |
1374 |
06B6: MOVWF 43 |
3283 |
kakl |
1375 |
06B7: MOVF 79,W |
3286 |
kaklik |
1376 |
06B8: MOVWF 44 |
3283 |
kakl |
1377 |
06B9: MOVF 7A,W |
3286 |
kaklik |
1378 |
06BA: MOVWF 45 |
|
|
1379 |
06BB: MOVWF 54 |
3283 |
kakl |
1380 |
06BC: MOVF 79,W |
3286 |
kaklik |
1381 |
06BD: MOVWF 53 |
3283 |
kakl |
1382 |
06BE: MOVF 78,W |
3286 |
kaklik |
1383 |
06BF: MOVWF 52 |
3283 |
kakl |
1384 |
06C0: MOVF 77,W |
3286 |
kaklik |
1385 |
06C1: MOVWF 51 |
|
|
1386 |
06C2: CLRF 58 |
3283 |
kakl |
1387 |
06C3: MOVLW FF |
3286 |
kaklik |
1388 |
06C4: MOVWF 57 |
3283 |
kakl |
1389 |
06C5: MOVLW 7F |
3286 |
kaklik |
1390 |
06C6: MOVWF 56 |
3283 |
kakl |
1391 |
06C7: MOVLW 8E |
3286 |
kaklik |
1392 |
06C8: MOVWF 55 |
3283 |
kakl |
1393 |
06C9: CALL 2E7 |
3286 |
kaklik |
1394 |
06CA: CLRF 4D |
|
|
1395 |
06CB: CLRF 4C |
3283 |
kakl |
1396 |
06CC: MOVLW 7A |
3286 |
kaklik |
1397 |
06CD: MOVWF 4B |
3283 |
kakl |
1398 |
06CE: MOVLW 85 |
3286 |
kaklik |
1399 |
06CF: MOVWF 4A |
3283 |
kakl |
1400 |
06D0: MOVF 7A,W |
3286 |
kaklik |
1401 |
06D1: MOVWF 51 |
3283 |
kakl |
1402 |
06D2: MOVF 79,W |
3286 |
kaklik |
1403 |
06D3: MOVWF 50 |
3283 |
kakl |
1404 |
06D4: MOVF 78,W |
3286 |
kaklik |
1405 |
06D5: MOVWF 4F |
3283 |
kakl |
1406 |
06D6: MOVF 77,W |
3286 |
kaklik |
1407 |
06D7: MOVWF 4E |
3283 |
kakl |
1408 |
06D8: CALL 3B1 |
|
|
1409 |
06D9: BCF 03.1 |
3286 |
kaklik |
1410 |
06DA: CLRF 56 |
|
|
1411 |
06DB: CLRF 55 |
3283 |
kakl |
1412 |
06DC: MOVLW C0 |
3286 |
kaklik |
1413 |
06DD: MOVWF 54 |
3283 |
kakl |
1414 |
06DE: MOVLW 81 |
3286 |
kaklik |
1415 |
06DF: MOVWF 53 |
3283 |
kakl |
1416 |
06E0: MOVF 7A,W |
3286 |
kaklik |
1417 |
06E1: MOVWF 5A |
3283 |
kakl |
1418 |
06E2: MOVF 79,W |
3286 |
kaklik |
1419 |
06E3: MOVWF 59 |
3283 |
kakl |
1420 |
06E4: MOVF 78,W |
3286 |
kaklik |
1421 |
06E5: MOVWF 58 |
3283 |
kakl |
1422 |
06E6: MOVF 77,W |
3286 |
kaklik |
1423 |
06E7: MOVWF 57 |
3283 |
kakl |
1424 |
06E8: CALL 426 |
3275 |
kaklik |
1425 |
.................... } |
3283 |
kakl |
1426 |
06E9: BSF 0A.3 |
|
|
1427 |
06EA: BCF 0A.4 |
3286 |
kaklik |
1428 |
06EB: GOTO 5C4 (RETURN) |
3275 |
kaklik |
1429 |
.................... |
|
|
1430 |
.................... |
|
|
1431 |
.................... |
|
|
1432 |
.................... |
|
|
1433 |
.................... #include "../LTS01.h" |
|
|
1434 |
.................... //Adresa pro VDD, VDD, VDD W 0x9E R 0x9F |
|
|
1435 |
.................... //Adresa pro GND GND GND W 0x90 R 0x91 |
|
|
1436 |
.................... |
|
|
1437 |
.................... #define LTS01A_address 0x90 |
|
|
1438 |
.................... |
|
|
1439 |
.................... #include "LTS01.c" |
|
|
1440 |
.................... float LTS01_get_temp() |
|
|
1441 |
.................... { |
|
|
1442 |
.................... unsigned int8 MSB; |
|
|
1443 |
.................... unsigned int8 LSB; |
|
|
1444 |
.................... signed int16 data; |
|
|
1445 |
.................... |
|
|
1446 |
.................... i2c_start(); |
3283 |
kakl |
1447 |
06EC: BSF 20.4 |
|
|
1448 |
06ED: MOVF 20,W |
|
|
1449 |
06EE: BSF 03.5 |
|
|
1450 |
06EF: MOVWF 07 |
|
|
1451 |
06F0: NOP |
|
|
1452 |
06F1: BCF 03.5 |
|
|
1453 |
06F2: BSF 20.3 |
|
|
1454 |
06F3: MOVF 20,W |
|
|
1455 |
06F4: BSF 03.5 |
|
|
1456 |
06F5: MOVWF 07 |
|
|
1457 |
06F6: NOP |
|
|
1458 |
06F7: BCF 03.5 |
|
|
1459 |
06F8: BCF 07.4 |
|
|
1460 |
06F9: BCF 20.4 |
|
|
1461 |
06FA: MOVF 20,W |
|
|
1462 |
06FB: BSF 03.5 |
|
|
1463 |
06FC: MOVWF 07 |
|
|
1464 |
06FD: NOP |
|
|
1465 |
06FE: BCF 03.5 |
|
|
1466 |
06FF: BCF 07.3 |
|
|
1467 |
0700: BCF 20.3 |
|
|
1468 |
0701: MOVF 20,W |
|
|
1469 |
0702: BSF 03.5 |
|
|
1470 |
0703: MOVWF 07 |
3275 |
kaklik |
1471 |
.................... I2C_Write(LTS01A_address); |
3283 |
kakl |
1472 |
0704: MOVLW 90 |
|
|
1473 |
0705: BCF 03.5 |
3286 |
kaklik |
1474 |
0706: MOVWF 4E |
3283 |
kakl |
1475 |
0707: CALL 078 |
3275 |
kaklik |
1476 |
.................... I2C_write(0x00); |
3286 |
kaklik |
1477 |
0708: CLRF 4E |
3283 |
kakl |
1478 |
0709: CALL 078 |
3275 |
kaklik |
1479 |
.................... i2c_stop(); |
3283 |
kakl |
1480 |
070A: BCF 20.4 |
|
|
1481 |
070B: MOVF 20,W |
|
|
1482 |
070C: BSF 03.5 |
|
|
1483 |
070D: MOVWF 07 |
|
|
1484 |
070E: NOP |
|
|
1485 |
070F: BCF 03.5 |
|
|
1486 |
0710: BSF 20.3 |
|
|
1487 |
0711: MOVF 20,W |
|
|
1488 |
0712: BSF 03.5 |
|
|
1489 |
0713: MOVWF 07 |
|
|
1490 |
0714: BCF 03.5 |
|
|
1491 |
0715: BTFSS 07.3 |
|
|
1492 |
0716: GOTO 715 |
|
|
1493 |
0717: NOP |
|
|
1494 |
0718: GOTO 719 |
|
|
1495 |
0719: NOP |
|
|
1496 |
071A: BSF 20.4 |
|
|
1497 |
071B: MOVF 20,W |
|
|
1498 |
071C: BSF 03.5 |
|
|
1499 |
071D: MOVWF 07 |
|
|
1500 |
071E: NOP |
3275 |
kaklik |
1501 |
.................... i2c_start(); |
3283 |
kakl |
1502 |
071F: BCF 03.5 |
|
|
1503 |
0720: BSF 20.4 |
|
|
1504 |
0721: MOVF 20,W |
|
|
1505 |
0722: BSF 03.5 |
|
|
1506 |
0723: MOVWF 07 |
|
|
1507 |
0724: NOP |
|
|
1508 |
0725: BCF 03.5 |
|
|
1509 |
0726: BSF 20.3 |
|
|
1510 |
0727: MOVF 20,W |
|
|
1511 |
0728: BSF 03.5 |
|
|
1512 |
0729: MOVWF 07 |
|
|
1513 |
072A: NOP |
|
|
1514 |
072B: BCF 03.5 |
|
|
1515 |
072C: BCF 07.4 |
|
|
1516 |
072D: BCF 20.4 |
|
|
1517 |
072E: MOVF 20,W |
|
|
1518 |
072F: BSF 03.5 |
|
|
1519 |
0730: MOVWF 07 |
|
|
1520 |
0731: NOP |
|
|
1521 |
0732: BCF 03.5 |
|
|
1522 |
0733: BCF 07.3 |
|
|
1523 |
0734: BCF 20.3 |
|
|
1524 |
0735: MOVF 20,W |
|
|
1525 |
0736: BSF 03.5 |
|
|
1526 |
0737: MOVWF 07 |
3275 |
kaklik |
1527 |
.................... I2C_Write(LTS01A_address+1); |
3283 |
kakl |
1528 |
0738: MOVLW 91 |
|
|
1529 |
0739: BCF 03.5 |
3286 |
kaklik |
1530 |
073A: MOVWF 4E |
3283 |
kakl |
1531 |
073B: CALL 078 |
3275 |
kaklik |
1532 |
.................... MSB=i2c_read(1); |
3283 |
kakl |
1533 |
073C: MOVLW 01 |
|
|
1534 |
073D: MOVWF 77 |
|
|
1535 |
073E: CALL 285 |
|
|
1536 |
073F: MOVF 78,W |
3286 |
kaklik |
1537 |
0740: MOVWF 3D |
3275 |
kaklik |
1538 |
.................... LSB=i2c_read(0); |
3283 |
kakl |
1539 |
0741: CLRF 77 |
|
|
1540 |
0742: CALL 285 |
|
|
1541 |
0743: MOVF 78,W |
3286 |
kaklik |
1542 |
0744: MOVWF 3E |
3275 |
kaklik |
1543 |
.................... i2c_stop(); |
3283 |
kakl |
1544 |
0745: BCF 20.4 |
|
|
1545 |
0746: MOVF 20,W |
|
|
1546 |
0747: BSF 03.5 |
|
|
1547 |
0748: MOVWF 07 |
|
|
1548 |
0749: NOP |
|
|
1549 |
074A: BCF 03.5 |
|
|
1550 |
074B: BSF 20.3 |
|
|
1551 |
074C: MOVF 20,W |
|
|
1552 |
074D: BSF 03.5 |
|
|
1553 |
074E: MOVWF 07 |
|
|
1554 |
074F: BCF 03.5 |
|
|
1555 |
0750: BTFSS 07.3 |
|
|
1556 |
0751: GOTO 750 |
|
|
1557 |
0752: NOP |
|
|
1558 |
0753: GOTO 754 |
|
|
1559 |
0754: NOP |
|
|
1560 |
0755: BSF 20.4 |
|
|
1561 |
0756: MOVF 20,W |
|
|
1562 |
0757: BSF 03.5 |
|
|
1563 |
0758: MOVWF 07 |
|
|
1564 |
0759: NOP |
3275 |
kaklik |
1565 |
.................... |
|
|
1566 |
.................... data = MAKE16(MSB,LSB); |
3283 |
kakl |
1567 |
075A: BCF 03.5 |
3286 |
kaklik |
1568 |
075B: MOVF 3D,W |
|
|
1569 |
075C: MOVWF 40 |
|
|
1570 |
075D: MOVF 3E,W |
|
|
1571 |
075E: MOVWF 3F |
3275 |
kaklik |
1572 |
.................... |
|
|
1573 |
.................... return (data * 0.00390625 ); |
3286 |
kaklik |
1574 |
075F: MOVF 40,W |
|
|
1575 |
0760: MOVWF 42 |
|
|
1576 |
0761: MOVF 3F,W |
|
|
1577 |
0762: MOVWF 41 |
|
|
1578 |
0763: MOVF 42,W |
|
|
1579 |
0764: MOVWF 44 |
|
|
1580 |
0765: MOVF 41,W |
|
|
1581 |
0766: MOVWF 43 |
3275 |
kaklik |
1582 |
* |
3283 |
kakl |
1583 |
078B: MOVF 7A,W |
3286 |
kaklik |
1584 |
078C: MOVWF 4D |
3283 |
kakl |
1585 |
078D: MOVF 79,W |
3286 |
kaklik |
1586 |
078E: MOVWF 4C |
3283 |
kakl |
1587 |
078F: MOVF 78,W |
3286 |
kaklik |
1588 |
0790: MOVWF 4B |
3283 |
kakl |
1589 |
0791: MOVF 77,W |
3286 |
kaklik |
1590 |
0792: MOVWF 4A |
|
|
1591 |
0793: CLRF 51 |
|
|
1592 |
0794: CLRF 50 |
|
|
1593 |
0795: CLRF 4F |
3283 |
kakl |
1594 |
0796: MOVLW 77 |
3286 |
kaklik |
1595 |
0797: MOVWF 4E |
3283 |
kakl |
1596 |
0798: CALL 3B1 |
3275 |
kaklik |
1597 |
.................... |
|
|
1598 |
.................... } |
3283 |
kakl |
1599 |
0799: BSF 0A.3 |
|
|
1600 |
079A: BCF 0A.4 |
3286 |
kaklik |
1601 |
079B: GOTO 5CF (RETURN) |
3275 |
kaklik |
1602 |
.................... |
|
|
1603 |
.................... |
|
|
1604 |
.................... |
3283 |
kakl |
1605 |
.................... #include "./HMC5883L.h" |
|
|
1606 |
.................... // i2c slave addresses |
|
|
1607 |
.................... #define HMC5883L_WRT_ADDR 0x3C |
|
|
1608 |
.................... #define HMC5883L_READ_ADDR 0x3D |
3275 |
kaklik |
1609 |
.................... |
3283 |
kakl |
1610 |
.................... // Register addresses |
|
|
1611 |
.................... #define HMC5883L_CFG_A_REG 0x00 |
|
|
1612 |
.................... #define HMC5883L_CFG_B_REG 0x01 |
|
|
1613 |
.................... #define HMC5883L_MODE_REG 0x02 |
|
|
1614 |
.................... #define HMC5883L_X_MSB_REG 0x03 |
|
|
1615 |
.................... |
|
|
1616 |
.................... //Konstanty nastavujici rozsah |
|
|
1617 |
.................... //pro void set_mag_roz (unsigned int8 h) |
|
|
1618 |
.................... #define MAG_ROZ088 0x00 |
|
|
1619 |
.................... #define MAG_ROZ130 0x20 |
|
|
1620 |
.................... #define MAG_ROZ190 0x40 |
|
|
1621 |
.................... #define MAG_ROZ250 0x60 |
|
|
1622 |
.................... #define MAG_ROZ400 0x80 |
|
|
1623 |
.................... #define MAG_ROZ470 0xA0 |
|
|
1624 |
.................... #define MAG_ROZ560 0xC0 |
|
|
1625 |
.................... #define MAG_ROZ810 0xE0 |
|
|
1626 |
.................... |
|
|
1627 |
.................... |
|
|
1628 |
.................... #include "HMC5883L.c" |
|
|
1629 |
.................... //------------------------------ |
|
|
1630 |
.................... // Low level routines |
|
|
1631 |
.................... //------------------------------ |
|
|
1632 |
.................... void hmc5883l_write_reg(int8 reg, int8 data) |
|
|
1633 |
.................... { |
|
|
1634 |
.................... i2c_start(); |
|
|
1635 |
* |
|
|
1636 |
00C2: BSF 20.4 |
|
|
1637 |
00C3: MOVF 20,W |
|
|
1638 |
00C4: BSF 03.5 |
|
|
1639 |
00C5: MOVWF 07 |
|
|
1640 |
00C6: NOP |
|
|
1641 |
00C7: BCF 03.5 |
|
|
1642 |
00C8: BSF 20.3 |
|
|
1643 |
00C9: MOVF 20,W |
|
|
1644 |
00CA: BSF 03.5 |
|
|
1645 |
00CB: MOVWF 07 |
|
|
1646 |
00CC: NOP |
|
|
1647 |
00CD: BCF 03.5 |
|
|
1648 |
00CE: BCF 07.4 |
|
|
1649 |
00CF: BCF 20.4 |
|
|
1650 |
00D0: MOVF 20,W |
|
|
1651 |
00D1: BSF 03.5 |
|
|
1652 |
00D2: MOVWF 07 |
|
|
1653 |
00D3: NOP |
|
|
1654 |
00D4: BCF 03.5 |
|
|
1655 |
00D5: BCF 07.3 |
|
|
1656 |
00D6: BCF 20.3 |
|
|
1657 |
00D7: MOVF 20,W |
|
|
1658 |
00D8: BSF 03.5 |
|
|
1659 |
00D9: MOVWF 07 |
|
|
1660 |
.................... i2c_write(HMC5883L_WRT_ADDR); |
|
|
1661 |
00DA: MOVLW 3C |
|
|
1662 |
00DB: BCF 03.5 |
3286 |
kaklik |
1663 |
00DC: MOVWF 4E |
3283 |
kakl |
1664 |
00DD: CALL 078 |
|
|
1665 |
.................... i2c_write(reg); |
3286 |
kaklik |
1666 |
00DE: MOVF 3D,W |
|
|
1667 |
00DF: MOVWF 4E |
3283 |
kakl |
1668 |
00E0: CALL 078 |
|
|
1669 |
.................... i2c_write(data); |
3286 |
kaklik |
1670 |
00E1: MOVF 3E,W |
|
|
1671 |
00E2: MOVWF 4E |
3283 |
kakl |
1672 |
00E3: CALL 078 |
|
|
1673 |
.................... i2c_stop(); |
|
|
1674 |
00E4: BCF 20.4 |
|
|
1675 |
00E5: MOVF 20,W |
|
|
1676 |
00E6: BSF 03.5 |
|
|
1677 |
00E7: MOVWF 07 |
|
|
1678 |
00E8: NOP |
|
|
1679 |
00E9: BCF 03.5 |
|
|
1680 |
00EA: BSF 20.3 |
|
|
1681 |
00EB: MOVF 20,W |
|
|
1682 |
00EC: BSF 03.5 |
|
|
1683 |
00ED: MOVWF 07 |
|
|
1684 |
00EE: BCF 03.5 |
|
|
1685 |
00EF: BTFSS 07.3 |
|
|
1686 |
00F0: GOTO 0EF |
|
|
1687 |
00F1: NOP |
|
|
1688 |
00F2: GOTO 0F3 |
|
|
1689 |
00F3: NOP |
|
|
1690 |
00F4: BSF 20.4 |
|
|
1691 |
00F5: MOVF 20,W |
|
|
1692 |
00F6: BSF 03.5 |
|
|
1693 |
00F7: MOVWF 07 |
|
|
1694 |
00F8: NOP |
|
|
1695 |
.................... } |
|
|
1696 |
00F9: BCF 03.5 |
|
|
1697 |
00FA: RETURN |
|
|
1698 |
.................... |
|
|
1699 |
.................... //------------------------------ |
|
|
1700 |
.................... int8 hmc5883l_read_reg(int8 reg) |
|
|
1701 |
.................... { |
|
|
1702 |
.................... int8 retval; |
|
|
1703 |
.................... |
|
|
1704 |
.................... i2c_start(); |
|
|
1705 |
.................... i2c_write(HMC5883L_WRT_ADDR); |
|
|
1706 |
.................... i2c_write(reg); |
|
|
1707 |
.................... i2c_start(); |
|
|
1708 |
.................... i2c_write(HMC5883L_READ_ADDR); |
|
|
1709 |
.................... retval = i2c_read(0); |
|
|
1710 |
.................... i2c_stop(); |
|
|
1711 |
.................... |
|
|
1712 |
.................... return(retval); |
|
|
1713 |
.................... } |
|
|
1714 |
.................... |
|
|
1715 |
.................... //------------------------------ |
|
|
1716 |
.................... typedef struct |
|
|
1717 |
.................... { |
|
|
1718 |
.................... signed int16 x; |
|
|
1719 |
.................... signed int16 y; |
|
|
1720 |
.................... signed int16 z; |
|
|
1721 |
.................... }hmc5883l_result; |
|
|
1722 |
.................... |
|
|
1723 |
.................... // This global structure holds the values read |
|
|
1724 |
.................... // from the HMC5883L x,y,z registers. |
|
|
1725 |
.................... hmc5883l_result compass = {0,0,0}; |
|
|
1726 |
* |
3286 |
kaklik |
1727 |
0D09: CLRF 21 |
|
|
1728 |
0D0A: CLRF 22 |
|
|
1729 |
0D0B: CLRF 23 |
|
|
1730 |
0D0C: CLRF 24 |
|
|
1731 |
0D0D: CLRF 25 |
|
|
1732 |
0D0E: CLRF 26 |
3283 |
kakl |
1733 |
.................... |
|
|
1734 |
.................... //------------------------------ |
|
|
1735 |
.................... void hmc5883l_read_data(void) |
|
|
1736 |
.................... { |
|
|
1737 |
.................... unsigned int8 x_lsb; |
|
|
1738 |
.................... unsigned int8 x_msb; |
|
|
1739 |
.................... |
|
|
1740 |
.................... unsigned int8 y_lsb; |
|
|
1741 |
.................... unsigned int8 y_msb; |
|
|
1742 |
.................... |
|
|
1743 |
.................... unsigned int8 z_lsb; |
|
|
1744 |
.................... unsigned int8 z_msb; |
|
|
1745 |
.................... |
|
|
1746 |
.................... i2c_start(); |
|
|
1747 |
* |
|
|
1748 |
0800: BSF 20.4 |
|
|
1749 |
0801: MOVF 20,W |
|
|
1750 |
0802: BSF 03.5 |
|
|
1751 |
0803: MOVWF 07 |
|
|
1752 |
0804: NOP |
|
|
1753 |
0805: BCF 03.5 |
|
|
1754 |
0806: BSF 20.3 |
|
|
1755 |
0807: MOVF 20,W |
|
|
1756 |
0808: BSF 03.5 |
|
|
1757 |
0809: MOVWF 07 |
|
|
1758 |
080A: NOP |
|
|
1759 |
080B: BCF 03.5 |
|
|
1760 |
080C: BCF 07.4 |
|
|
1761 |
080D: BCF 20.4 |
|
|
1762 |
080E: MOVF 20,W |
|
|
1763 |
080F: BSF 03.5 |
|
|
1764 |
0810: MOVWF 07 |
|
|
1765 |
0811: NOP |
|
|
1766 |
0812: BCF 03.5 |
|
|
1767 |
0813: BCF 07.3 |
|
|
1768 |
0814: BCF 20.3 |
|
|
1769 |
0815: MOVF 20,W |
|
|
1770 |
0816: BSF 03.5 |
|
|
1771 |
0817: MOVWF 07 |
|
|
1772 |
.................... i2c_write(HMC5883L_WRT_ADDR); |
|
|
1773 |
0818: MOVLW 3C |
|
|
1774 |
0819: BCF 03.5 |
3286 |
kaklik |
1775 |
081A: MOVWF 4E |
3283 |
kakl |
1776 |
081B: BCF 0A.3 |
|
|
1777 |
081C: CALL 078 |
|
|
1778 |
081D: BSF 0A.3 |
|
|
1779 |
.................... i2c_write(HMC5883L_X_MSB_REG); // Point to X-msb register |
|
|
1780 |
081E: MOVLW 03 |
3286 |
kaklik |
1781 |
081F: MOVWF 4E |
3283 |
kakl |
1782 |
0820: BCF 0A.3 |
|
|
1783 |
0821: CALL 078 |
|
|
1784 |
0822: BSF 0A.3 |
|
|
1785 |
.................... i2c_start(); |
|
|
1786 |
0823: BSF 20.4 |
|
|
1787 |
0824: MOVF 20,W |
|
|
1788 |
0825: BSF 03.5 |
|
|
1789 |
0826: MOVWF 07 |
|
|
1790 |
0827: NOP |
|
|
1791 |
0828: BCF 03.5 |
|
|
1792 |
0829: BSF 20.3 |
|
|
1793 |
082A: MOVF 20,W |
|
|
1794 |
082B: BSF 03.5 |
|
|
1795 |
082C: MOVWF 07 |
|
|
1796 |
082D: NOP |
|
|
1797 |
082E: BCF 03.5 |
|
|
1798 |
082F: BTFSS 07.3 |
|
|
1799 |
0830: GOTO 02F |
|
|
1800 |
0831: BCF 07.4 |
|
|
1801 |
0832: BCF 20.4 |
|
|
1802 |
0833: MOVF 20,W |
|
|
1803 |
0834: BSF 03.5 |
|
|
1804 |
0835: MOVWF 07 |
|
|
1805 |
0836: NOP |
|
|
1806 |
0837: BCF 03.5 |
|
|
1807 |
0838: BCF 07.3 |
|
|
1808 |
0839: BCF 20.3 |
|
|
1809 |
083A: MOVF 20,W |
|
|
1810 |
083B: BSF 03.5 |
|
|
1811 |
083C: MOVWF 07 |
|
|
1812 |
.................... i2c_write(HMC5883L_READ_ADDR); |
|
|
1813 |
083D: MOVLW 3D |
|
|
1814 |
083E: BCF 03.5 |
3286 |
kaklik |
1815 |
083F: MOVWF 4E |
3283 |
kakl |
1816 |
0840: BCF 0A.3 |
|
|
1817 |
0841: CALL 078 |
|
|
1818 |
0842: BSF 0A.3 |
|
|
1819 |
.................... |
|
|
1820 |
.................... x_msb = i2c_read(); |
|
|
1821 |
0843: MOVLW 01 |
|
|
1822 |
0844: MOVWF 77 |
|
|
1823 |
0845: BCF 0A.3 |
|
|
1824 |
0846: CALL 285 |
|
|
1825 |
0847: BSF 0A.3 |
|
|
1826 |
0848: MOVF 78,W |
3286 |
kaklik |
1827 |
0849: MOVWF 3E |
3283 |
kakl |
1828 |
.................... x_lsb = i2c_read(); |
|
|
1829 |
084A: MOVLW 01 |
|
|
1830 |
084B: MOVWF 77 |
|
|
1831 |
084C: BCF 0A.3 |
|
|
1832 |
084D: CALL 285 |
|
|
1833 |
084E: BSF 0A.3 |
|
|
1834 |
084F: MOVF 78,W |
3286 |
kaklik |
1835 |
0850: MOVWF 3D |
3283 |
kakl |
1836 |
.................... |
|
|
1837 |
.................... z_msb = i2c_read(); |
|
|
1838 |
0851: MOVLW 01 |
|
|
1839 |
0852: MOVWF 77 |
|
|
1840 |
0853: BCF 0A.3 |
|
|
1841 |
0854: CALL 285 |
|
|
1842 |
0855: BSF 0A.3 |
|
|
1843 |
0856: MOVF 78,W |
3286 |
kaklik |
1844 |
0857: MOVWF 42 |
3283 |
kakl |
1845 |
.................... z_lsb = i2c_read(); |
|
|
1846 |
0858: MOVLW 01 |
|
|
1847 |
0859: MOVWF 77 |
|
|
1848 |
085A: BCF 0A.3 |
|
|
1849 |
085B: CALL 285 |
|
|
1850 |
085C: BSF 0A.3 |
|
|
1851 |
085D: MOVF 78,W |
3286 |
kaklik |
1852 |
085E: MOVWF 41 |
3283 |
kakl |
1853 |
.................... |
|
|
1854 |
.................... y_msb = i2c_read(); |
|
|
1855 |
085F: MOVLW 01 |
|
|
1856 |
0860: MOVWF 77 |
|
|
1857 |
0861: BCF 0A.3 |
|
|
1858 |
0862: CALL 285 |
|
|
1859 |
0863: BSF 0A.3 |
|
|
1860 |
0864: MOVF 78,W |
3286 |
kaklik |
1861 |
0865: MOVWF 40 |
3283 |
kakl |
1862 |
.................... y_lsb = i2c_read(0); // do a NACK on last read |
|
|
1863 |
0866: CLRF 77 |
|
|
1864 |
0867: BCF 0A.3 |
|
|
1865 |
0868: CALL 285 |
|
|
1866 |
0869: BSF 0A.3 |
|
|
1867 |
086A: MOVF 78,W |
3286 |
kaklik |
1868 |
086B: MOVWF 3F |
3283 |
kakl |
1869 |
.................... |
|
|
1870 |
.................... i2c_stop(); |
|
|
1871 |
086C: BCF 20.4 |
|
|
1872 |
086D: MOVF 20,W |
|
|
1873 |
086E: BSF 03.5 |
|
|
1874 |
086F: MOVWF 07 |
|
|
1875 |
0870: NOP |
|
|
1876 |
0871: BCF 03.5 |
|
|
1877 |
0872: BSF 20.3 |
|
|
1878 |
0873: MOVF 20,W |
|
|
1879 |
0874: BSF 03.5 |
|
|
1880 |
0875: MOVWF 07 |
|
|
1881 |
0876: BCF 03.5 |
|
|
1882 |
0877: BTFSS 07.3 |
|
|
1883 |
0878: GOTO 077 |
|
|
1884 |
0879: NOP |
|
|
1885 |
087A: GOTO 07B |
|
|
1886 |
087B: NOP |
|
|
1887 |
087C: BSF 20.4 |
|
|
1888 |
087D: MOVF 20,W |
|
|
1889 |
087E: BSF 03.5 |
|
|
1890 |
087F: MOVWF 07 |
|
|
1891 |
0880: NOP |
|
|
1892 |
.................... |
|
|
1893 |
.................... // Combine high and low bytes into 16-bit values. |
|
|
1894 |
.................... compass.x = make16(x_msb, x_lsb); |
|
|
1895 |
0881: BCF 03.5 |
3286 |
kaklik |
1896 |
0882: MOVF 3E,W |
3283 |
kakl |
1897 |
0883: MOVWF 22 |
3286 |
kaklik |
1898 |
0884: MOVF 3D,W |
3283 |
kakl |
1899 |
0885: MOVWF 21 |
|
|
1900 |
.................... compass.y = make16(y_msb, y_lsb); |
3286 |
kaklik |
1901 |
0886: MOVF 40,W |
3283 |
kakl |
1902 |
0887: MOVWF 24 |
3286 |
kaklik |
1903 |
0888: MOVF 3F,W |
3283 |
kakl |
1904 |
0889: MOVWF 23 |
|
|
1905 |
.................... compass.z = make16(z_msb, z_lsb); |
3286 |
kaklik |
1906 |
088A: MOVF 42,W |
3283 |
kakl |
1907 |
088B: MOVWF 26 |
3286 |
kaklik |
1908 |
088C: MOVF 41,W |
3283 |
kakl |
1909 |
088D: MOVWF 25 |
|
|
1910 |
.................... } |
|
|
1911 |
088E: BSF 0A.3 |
|
|
1912 |
088F: BCF 0A.4 |
3286 |
kaklik |
1913 |
0890: GOTO 5D9 (RETURN) |
3283 |
kakl |
1914 |
.................... |
|
|
1915 |
.................... |
|
|
1916 |
.................... |
|
|
1917 |
.................... |
|
|
1918 |
.................... #include <math.h> |
|
|
1919 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
1920 |
.................... //// (C) Copyright 1996,2008 Custom Computer Services //// |
|
|
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 //// |
|
|
1923 |
.................... //// licensed users of the CCS C compiler. No other use, reproduction //// |
|
|
1924 |
.................... //// or distribution is permitted without written permission. //// |
|
|
1925 |
.................... //// Derivative programs created using this software in object code //// |
|
|
1926 |
.................... //// form are not restricted in any way. //// |
|
|
1927 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
1928 |
.................... //// //// |
|
|
1929 |
.................... //// History: //// |
|
|
1930 |
.................... //// * 9/20/2001 : Improvments are made to sin/cos code. //// |
|
|
1931 |
.................... //// The code now is small, much faster, //// |
|
|
1932 |
.................... //// and more accurate. //// |
|
|
1933 |
.................... //// * 2/21/2007 : Compiler handles & operator differently and does |
|
|
1934 |
.................... //// not return generic (int8 *) so type cast is done //// |
|
|
1935 |
.................... //// //// |
|
|
1936 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
1937 |
.................... |
|
|
1938 |
.................... #ifndef MATH_H |
|
|
1939 |
.................... #define MATH_H |
|
|
1940 |
.................... |
|
|
1941 |
.................... #ifdef PI |
|
|
1942 |
.................... #undef PI |
|
|
1943 |
.................... #endif |
|
|
1944 |
.................... #define PI 3.1415926535897932 |
|
|
1945 |
.................... |
|
|
1946 |
.................... |
|
|
1947 |
.................... #define SQRT2 1.4142135623730950 |
|
|
1948 |
.................... |
|
|
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}; |
|
|
1951 |
.................... |
|
|
1952 |
.................... ///////////////////////////// Round Functions ////////////////////////////// |
|
|
1953 |
.................... |
|
|
1954 |
.................... float32 CEIL_FLOOR(float32 x, unsigned int8 n) |
|
|
1955 |
.................... { |
|
|
1956 |
.................... float32 y, res; |
|
|
1957 |
.................... unsigned int16 l; |
|
|
1958 |
.................... int1 s; |
|
|
1959 |
.................... |
|
|
1960 |
.................... s = 0; |
|
|
1961 |
.................... y = x; |
|
|
1962 |
.................... |
|
|
1963 |
.................... if (x < 0) |
|
|
1964 |
.................... { |
|
|
1965 |
.................... s = 1; |
|
|
1966 |
.................... y = -y; |
|
|
1967 |
.................... } |
|
|
1968 |
.................... |
|
|
1969 |
.................... if (y <= 32768.0) |
|
|
1970 |
.................... res = (float32)(unsigned int16)y; |
|
|
1971 |
.................... |
|
|
1972 |
.................... else if (y < 10000000.0) |
|
|
1973 |
.................... { |
|
|
1974 |
.................... l = (unsigned int16)(y/32768.0); |
|
|
1975 |
.................... y = 32768.0*(y/32768.0 - (float32)l); |
|
|
1976 |
.................... res = 32768.0*(float32)l; |
|
|
1977 |
.................... res += (float32)(unsigned int16)y; |
|
|
1978 |
.................... } |
|
|
1979 |
.................... |
|
|
1980 |
.................... else |
|
|
1981 |
.................... res = y; |
|
|
1982 |
.................... |
|
|
1983 |
.................... y = y - (float32)(unsigned int16)y; |
|
|
1984 |
.................... |
|
|
1985 |
.................... if (s) |
|
|
1986 |
.................... res = -res; |
|
|
1987 |
.................... |
|
|
1988 |
.................... if (y != 0) |
|
|
1989 |
.................... { |
|
|
1990 |
.................... if (s == 1 && n == 0) |
|
|
1991 |
.................... res -= 1.0; |
|
|
1992 |
.................... |
|
|
1993 |
.................... if (s == 0 && n == 1) |
|
|
1994 |
.................... res += 1.0; |
|
|
1995 |
.................... } |
|
|
1996 |
.................... if (x == 0) |
|
|
1997 |
.................... res = 0; |
|
|
1998 |
.................... |
|
|
1999 |
.................... return (res); |
|
|
2000 |
.................... } |
|
|
2001 |
.................... |
|
|
2002 |
.................... // Overloaded Functions to take care for new Data types in PCD |
|
|
2003 |
.................... // Overloaded function CEIL_FLOOR() for data type - Float48 |
|
|
2004 |
.................... #if defined(__PCD__) |
|
|
2005 |
.................... float48 CEIL_FLOOR(float48 x, unsigned int8 n) |
|
|
2006 |
.................... { |
|
|
2007 |
.................... float48 y, res; |
|
|
2008 |
.................... unsigned int16 l; |
|
|
2009 |
.................... int1 s; |
|
|
2010 |
.................... |
|
|
2011 |
.................... s = 0; |
|
|
2012 |
.................... y = x; |
|
|
2013 |
.................... |
|
|
2014 |
.................... if (x < 0) |
|
|
2015 |
.................... { |
|
|
2016 |
.................... s = 1; |
|
|
2017 |
.................... y = -y; |
|
|
2018 |
.................... } |
|
|
2019 |
.................... |
|
|
2020 |
.................... if (y <= 32768.0) |
|
|
2021 |
.................... res = (float48)(unsigned int16)y; |
|
|
2022 |
.................... |
|
|
2023 |
.................... else if (y < 10000000.0) |
|
|
2024 |
.................... { |
|
|
2025 |
.................... l = (unsigned int16)(y/32768.0); |
|
|
2026 |
.................... y = 32768.0*(y/32768.0 - (float48)l); |
|
|
2027 |
.................... res = 32768.0*(float32)l; |
|
|
2028 |
.................... res += (float48)(unsigned int16)y; |
|
|
2029 |
.................... } |
|
|
2030 |
.................... |
|
|
2031 |
.................... else |
|
|
2032 |
.................... res = y; |
|
|
2033 |
.................... |
|
|
2034 |
.................... y = y - (float48)(unsigned int16)y; |
|
|
2035 |
.................... |
|
|
2036 |
.................... if (s) |
|
|
2037 |
.................... res = -res; |
|
|
2038 |
.................... |
|
|
2039 |
.................... if (y != 0) |
|
|
2040 |
.................... { |
|
|
2041 |
.................... if (s == 1 && n == 0) |
|
|
2042 |
.................... res -= 1.0; |
|
|
2043 |
.................... |
|
|
2044 |
.................... if (s == 0 && n == 1) |
|
|
2045 |
.................... res += 1.0; |
|
|
2046 |
.................... } |
|
|
2047 |
.................... if (x == 0) |
|
|
2048 |
.................... res = 0; |
|
|
2049 |
.................... |
|
|
2050 |
.................... return (res); |
|
|
2051 |
.................... } |
|
|
2052 |
.................... |
|
|
2053 |
.................... |
|
|
2054 |
.................... // Overloaded function CEIL_FLOOR() for data type - Float64 |
|
|
2055 |
.................... float64 CEIL_FLOOR(float64 x, unsigned int8 n) |
|
|
2056 |
.................... { |
|
|
2057 |
.................... float64 y, res; |
|
|
2058 |
.................... unsigned int16 l; |
|
|
2059 |
.................... int1 s; |
|
|
2060 |
.................... |
|
|
2061 |
.................... s = 0; |
|
|
2062 |
.................... y = x; |
|
|
2063 |
.................... |
|
|
2064 |
.................... if (x < 0) |
|
|
2065 |
.................... { |
|
|
2066 |
.................... s = 1; |
|
|
2067 |
.................... y = -y; |
|
|
2068 |
.................... } |
|
|
2069 |
.................... |
|
|
2070 |
.................... if (y <= 32768.0) |
|
|
2071 |
.................... res = (float64)(unsigned int16)y; |
|
|
2072 |
.................... |
|
|
2073 |
.................... else if (y < 10000000.0) |
|
|
2074 |
.................... { |
|
|
2075 |
.................... l = (unsigned int16)(y/32768.0); |
|
|
2076 |
.................... y = 32768.0*(y/32768.0 - (float64)l); |
|
|
2077 |
.................... res = 32768.0*(float64)l; |
|
|
2078 |
.................... res += (float64)(unsigned int16)y; |
|
|
2079 |
.................... } |
|
|
2080 |
.................... |
|
|
2081 |
.................... else |
|
|
2082 |
.................... res = y; |
|
|
2083 |
.................... |
|
|
2084 |
.................... y = y - (float64)(unsigned int16)y; |
|
|
2085 |
.................... |
|
|
2086 |
.................... if (s) |
|
|
2087 |
.................... res = -res; |
|
|
2088 |
.................... |
|
|
2089 |
.................... if (y != 0) |
|
|
2090 |
.................... { |
|
|
2091 |
.................... if (s == 1 && n == 0) |
|
|
2092 |
.................... res -= 1.0; |
|
|
2093 |
.................... |
|
|
2094 |
.................... if (s == 0 && n == 1) |
|
|
2095 |
.................... res += 1.0; |
|
|
2096 |
.................... } |
|
|
2097 |
.................... if (x == 0) |
|
|
2098 |
.................... res = 0; |
|
|
2099 |
.................... |
|
|
2100 |
.................... return (res); |
|
|
2101 |
.................... } |
|
|
2102 |
.................... #endif |
|
|
2103 |
.................... |
|
|
2104 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
2105 |
.................... // float floor(float x) |
|
|
2106 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
2107 |
.................... // Description : rounds down the number x. |
|
|
2108 |
.................... // Date : N/A |
|
|
2109 |
.................... // |
|
|
2110 |
.................... float32 floor(float32 x) |
|
|
2111 |
.................... { |
|
|
2112 |
.................... return CEIL_FLOOR(x, 0); |
|
|
2113 |
.................... } |
|
|
2114 |
.................... // Following 2 functions are overloaded functions of floor() for PCD |
|
|
2115 |
.................... // Overloaded function floor() for data type - Float48 |
|
|
2116 |
.................... #if defined(__PCD__) |
|
|
2117 |
.................... float48 floor(float48 x) |
|
|
2118 |
.................... { |
|
|
2119 |
.................... return CEIL_FLOOR(x, 0); |
|
|
2120 |
.................... } |
|
|
2121 |
.................... |
|
|
2122 |
.................... // Overloaded function floor() for data type - Float64 |
|
|
2123 |
.................... float64 floor(float64 x) |
|
|
2124 |
.................... { |
|
|
2125 |
.................... return CEIL_FLOOR(x, 0); |
|
|
2126 |
.................... } |
|
|
2127 |
.................... #endif |
|
|
2128 |
.................... |
|
|
2129 |
.................... |
|
|
2130 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
2131 |
.................... // float ceil(float x) |
|
|
2132 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
2133 |
.................... // Description : rounds up the number x. |
|
|
2134 |
.................... // Date : N/A |
|
|
2135 |
.................... // |
|
|
2136 |
.................... float32 ceil(float32 x) |
|
|
2137 |
.................... { |
|
|
2138 |
.................... return CEIL_FLOOR(x, 1); |
|
|
2139 |
.................... } |
|
|
2140 |
.................... // Following 2 functions are overloaded functions of ceil() for PCD |
|
|
2141 |
.................... // Overloaded function ceil() for data type - Float48 |
|
|
2142 |
.................... #if defined(__PCD__) |
|
|
2143 |
.................... float48 ceil(float48 x) |
|
|
2144 |
.................... { |
|
|
2145 |
.................... return CEIL_FLOOR(x, 1); |
|
|
2146 |
.................... } |
|
|
2147 |
.................... |
|
|
2148 |
.................... // Overloaded function ceil() for data type - Float64 |
|
|
2149 |
.................... float64 ceil(float64 x) |
|
|
2150 |
.................... { |
|
|
2151 |
.................... return CEIL_FLOOR(x, 1); |
|
|
2152 |
.................... } |
|
|
2153 |
.................... #endif |
|
|
2154 |
.................... |
|
|
2155 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
2156 |
.................... // float fabs(float x) |
|
|
2157 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
2158 |
.................... // Description : Computes the absolute value of floating point number x |
|
|
2159 |
.................... // Returns : returns the absolute value of x |
|
|
2160 |
.................... // Date : N/A |
|
|
2161 |
.................... // |
|
|
2162 |
.................... #define fabs abs |
|
|
2163 |
.................... |
|
|
2164 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
2165 |
.................... // float fmod(float x) |
|
|
2166 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
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 |
|
|
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. |
|
|
2171 |
.................... // Date : N/A |
|
|
2172 |
.................... // |
|
|
2173 |
.................... |
|
|
2174 |
.................... float fmod(float32 x,float32 y) |
|
|
2175 |
.................... { |
|
|
2176 |
.................... float32 i; |
|
|
2177 |
.................... if (y!=0.0) |
|
|
2178 |
.................... { |
|
|
2179 |
.................... i=(x/y < 0.0)? ceil(x/y): floor(x/y); |
|
|
2180 |
.................... return(x-(i*y)); |
|
|
2181 |
.................... } |
|
|
2182 |
.................... else |
|
|
2183 |
.................... { |
|
|
2184 |
.................... #ifdef _ERRNO |
|
|
2185 |
.................... { |
|
|
2186 |
.................... errno=EDOM; |
|
|
2187 |
.................... } |
|
|
2188 |
.................... #endif |
|
|
2189 |
.................... } |
|
|
2190 |
.................... } |
|
|
2191 |
.................... //Overloaded function for fmod() for PCD |
|
|
2192 |
.................... // Overloaded function fmod() for data type - Float48 |
|
|
2193 |
.................... #if defined(__PCD__) |
|
|
2194 |
.................... float48 fmod(float48 x,float48 y) |
|
|
2195 |
.................... { |
|
|
2196 |
.................... float48 i; |
|
|
2197 |
.................... if (y!=0.0) |
|
|
2198 |
.................... { |
|
|
2199 |
.................... i=(x/y < 0.0)? ceil(x/y): floor(x/y); |
|
|
2200 |
.................... return(x-(i*y)); |
|
|
2201 |
.................... } |
|
|
2202 |
.................... else |
|
|
2203 |
.................... { |
|
|
2204 |
.................... #ifdef _ERRNO |
|
|
2205 |
.................... { |
|
|
2206 |
.................... errno=EDOM; |
|
|
2207 |
.................... } |
|
|
2208 |
.................... #endif |
|
|
2209 |
.................... } |
|
|
2210 |
.................... } |
|
|
2211 |
.................... // Overloaded function fmod() for data type - Float64 |
|
|
2212 |
.................... float64 fmod(float64 x,float64 y) |
|
|
2213 |
.................... { |
|
|
2214 |
.................... float64 i; |
|
|
2215 |
.................... if (y!=0.0) |
|
|
2216 |
.................... { |
|
|
2217 |
.................... i=(x/y < 0.0)? ceil(x/y): floor(x/y); |
|
|
2218 |
.................... return(x-(i*y)); |
|
|
2219 |
.................... } |
|
|
2220 |
.................... else |
|
|
2221 |
.................... { |
|
|
2222 |
.................... #ifdef _ERRNO |
|
|
2223 |
.................... { |
|
|
2224 |
.................... errno=EDOM; |
|
|
2225 |
.................... } |
|
|
2226 |
.................... #endif |
|
|
2227 |
.................... } |
|
|
2228 |
.................... } |
|
|
2229 |
.................... #endif |
|
|
2230 |
.................... //////////////////// Exponential and logarithmic functions //////////////////// |
|
|
2231 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
2232 |
.................... // float exp(float x) |
|
|
2233 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
2234 |
.................... // Description : returns the value (e^x) |
|
|
2235 |
.................... // Date : N/A |
|
|
2236 |
.................... // |
|
|
2237 |
.................... #define LN2 0.6931471805599453 |
|
|
2238 |
.................... |
|
|
2239 |
.................... float const pe[6] = {0.000207455774, 0.00127100575, 0.00965065093, |
|
|
2240 |
.................... 0.0554965651, 0.240227138, 0.693147172}; |
|
|
2241 |
.................... |
|
|
2242 |
.................... |
|
|
2243 |
.................... float32 exp(float32 x) |
|
|
2244 |
.................... { |
|
|
2245 |
.................... float32 y, res, r; |
|
|
2246 |
.................... #if defined(__PCD__) |
|
|
2247 |
.................... int8 data1; |
|
|
2248 |
.................... #endif |
|
|
2249 |
.................... signed int8 n; |
|
|
2250 |
.................... int1 s; |
|
|
2251 |
.................... #ifdef _ERRNO |
|
|
2252 |
.................... if(x > 88.722838) |
|
|
2253 |
.................... { |
|
|
2254 |
.................... errno=ERANGE; |
|
|
2255 |
.................... return(0); |
|
|
2256 |
.................... } |
|
|
2257 |
.................... #endif |
|
|
2258 |
.................... n = (signed int16)(x/LN2); |
|
|
2259 |
.................... s = 0; |
|
|
2260 |
.................... y = x; |
|
|
2261 |
.................... |
|
|
2262 |
.................... if (x < 0) |
|
|
2263 |
.................... { |
|
|
2264 |
.................... s = 1; |
|
|
2265 |
.................... n = -n; |
|
|
2266 |
.................... y = -y; |
|
|
2267 |
.................... } |
|
|
2268 |
.................... |
|
|
2269 |
.................... res = 0.0; |
|
|
2270 |
.................... #if !defined(__PCD__) |
|
|
2271 |
.................... *((unsigned int8 *)(&res)) = n + 0x7F; |
|
|
2272 |
.................... #endif |
|
|
2273 |
.................... |
|
|
2274 |
.................... #if defined(__PCD__) // Takes care of IEEE format for PCD |
|
|
2275 |
.................... data1 = n+0x7F; |
|
|
2276 |
.................... if(bit_test(data1,0)) |
|
|
2277 |
.................... bit_set(*(((unsigned int8 *)(&res)+2)),7); |
|
|
2278 |
.................... rotate_right(&data1,1); |
|
|
2279 |
.................... bit_clear(data1,7); |
|
|
2280 |
.................... *(((unsigned int8 *)(&res)+3)) = data1; |
|
|
2281 |
.................... #endif |
|
|
2282 |
.................... |
|
|
2283 |
.................... y = y/LN2 - (float32)n; |
|
|
2284 |
.................... |
|
|
2285 |
.................... r = pe[0]*y + pe[1]; |
|
|
2286 |
.................... r = r*y + pe[2]; |
|
|
2287 |
.................... r = r*y + pe[3]; |
|
|
2288 |
.................... r = r*y + pe[4]; |
|
|
2289 |
.................... r = r*y + pe[5]; |
|
|
2290 |
.................... |
|
|
2291 |
.................... res = res*(1.0 + y*r); |
|
|
2292 |
.................... |
|
|
2293 |
.................... if (s) |
|
|
2294 |
.................... res = 1.0/res; |
|
|
2295 |
.................... return(res); |
|
|
2296 |
.................... } |
|
|
2297 |
.................... |
|
|
2298 |
.................... |
|
|
2299 |
.................... //Overloaded function for exp() for PCD |
|
|
2300 |
.................... // Overloaded function exp() for data type - Float48 |
|
|
2301 |
.................... #if defined(__PCD__) |
|
|
2302 |
.................... float48 exp(float48 x) |
|
|
2303 |
.................... { |
|
|
2304 |
.................... float48 y, res, r; |
|
|
2305 |
.................... int8 data1; |
|
|
2306 |
.................... signed int8 n; |
|
|
2307 |
.................... int1 s; |
|
|
2308 |
.................... #ifdef _ERRNO |
|
|
2309 |
.................... if(x > 88.722838) |
|
|
2310 |
.................... { |
|
|
2311 |
.................... errno=ERANGE; |
|
|
2312 |
.................... return(0); |
|
|
2313 |
.................... } |
|
|
2314 |
.................... #endif |
|
|
2315 |
.................... n = (signed int16)(x/LN2); |
|
|
2316 |
.................... s = 0; |
|
|
2317 |
.................... y = x; |
|
|
2318 |
.................... |
|
|
2319 |
.................... if (x < 0) |
|
|
2320 |
.................... { |
|
|
2321 |
.................... s = 1; |
|
|
2322 |
.................... n = -n; |
|
|
2323 |
.................... y = -y; |
|
|
2324 |
.................... } |
|
|
2325 |
.................... |
|
|
2326 |
.................... res = 0.0; |
|
|
2327 |
.................... |
|
|
2328 |
.................... data1 = n+0x7F; |
|
|
2329 |
.................... if(bit_test(data1,0)) |
|
|
2330 |
.................... bit_set(*(((unsigned int8 *)(&res)+4)),7); |
|
|
2331 |
.................... rotate_right(&data1,1); |
|
|
2332 |
.................... bit_clear(data1,7); |
|
|
2333 |
.................... *(((unsigned int8 *)(&res)+5)) = data1; |
|
|
2334 |
.................... |
|
|
2335 |
.................... y = y/LN2 - (float48)n; |
|
|
2336 |
.................... |
|
|
2337 |
.................... r = pe[0]*y + pe[1]; |
|
|
2338 |
.................... r = r*y + pe[2]; |
|
|
2339 |
.................... r = r*y + pe[3]; |
|
|
2340 |
.................... r = r*y + pe[4]; |
|
|
2341 |
.................... r = r*y + pe[5]; |
|
|
2342 |
.................... |
|
|
2343 |
.................... res = res*(1.0 + y*r); |
|
|
2344 |
.................... |
|
|
2345 |
.................... if (s) |
|
|
2346 |
.................... res = 1.0/res; |
|
|
2347 |
.................... return(res); |
|
|
2348 |
.................... } |
|
|
2349 |
.................... |
|
|
2350 |
.................... // Overloaded function exp() for data type - Float64 |
|
|
2351 |
.................... float64 exp(float64 x) |
|
|
2352 |
.................... { |
|
|
2353 |
.................... float64 y, res, r; |
|
|
2354 |
.................... unsigned int16 data1, data2; |
|
|
2355 |
.................... unsigned int16 *p; |
|
|
2356 |
.................... signed int16 n; |
|
|
2357 |
.................... int1 s; |
|
|
2358 |
.................... #ifdef _ERRNO |
|
|
2359 |
.................... if(x > 709.7827128) |
|
|
2360 |
.................... { |
|
|
2361 |
.................... errno=ERANGE; |
|
|
2362 |
.................... return(0); |
|
|
2363 |
.................... } |
|
|
2364 |
.................... #endif |
|
|
2365 |
.................... n = (signed int16)(x/LN2); |
|
|
2366 |
.................... s = 0; |
|
|
2367 |
.................... y = x; |
|
|
2368 |
.................... |
|
|
2369 |
.................... if (x < 0) |
|
|
2370 |
.................... { |
|
|
2371 |
.................... s = 1; |
|
|
2372 |
.................... n = -n; |
|
|
2373 |
.................... y = -y; |
|
|
2374 |
.................... } |
|
|
2375 |
.................... |
|
|
2376 |
.................... res = 0.0; |
|
|
2377 |
.................... |
|
|
2378 |
.................... #if !defined(__PCD__) |
|
|
2379 |
.................... *((unsigned int16 *)(&res)) = n + 0x7F; |
|
|
2380 |
.................... #endif |
|
|
2381 |
.................... p= (((unsigned int16 *)(&res))+3); |
|
|
2382 |
.................... data1 = *p; |
|
|
2383 |
.................... data2 = *p; |
|
|
2384 |
.................... data1 = n + 0x3FF; |
|
|
2385 |
.................... data1 = data1 <<4; |
|
|
2386 |
.................... if(bit_test(data2,15)) |
|
|
2387 |
.................... bit_set(data1,15); |
|
|
2388 |
.................... data2 = data2 & 0x000F; |
|
|
2389 |
.................... data1 ^= data2; |
|
|
2390 |
.................... |
|
|
2391 |
.................... *(((unsigned int16 *)(&res)+3)) = data1; |
|
|
2392 |
.................... |
|
|
2393 |
.................... |
|
|
2394 |
.................... y = y/LN2 - (float64)n; |
|
|
2395 |
.................... |
|
|
2396 |
.................... r = pe[0]*y + pe[1]; |
|
|
2397 |
.................... r = r*y + pe[2]; |
|
|
2398 |
.................... r = r*y + pe[3]; |
|
|
2399 |
.................... r = r*y + pe[4]; |
|
|
2400 |
.................... r = r*y + pe[5]; |
|
|
2401 |
.................... |
|
|
2402 |
.................... res = res*(1.0 + y*r); |
|
|
2403 |
.................... |
|
|
2404 |
.................... if (s) |
|
|
2405 |
.................... res = 1.0/res; |
|
|
2406 |
.................... return(res); |
|
|
2407 |
.................... } |
|
|
2408 |
.................... |
|
|
2409 |
.................... #ENDIF |
|
|
2410 |
.................... |
|
|
2411 |
.................... |
|
|
2412 |
.................... /************************************************************/ |
|
|
2413 |
.................... |
|
|
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}; |
|
|
2416 |
.................... |
|
|
2417 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
2418 |
.................... // float log(float x) |
|
|
2419 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
2420 |
.................... // Description : returns the the natural log of x |
|
|
2421 |
.................... // Date : N/A |
|
|
2422 |
.................... // |
|
|
2423 |
.................... float32 log(float32 x) |
|
|
2424 |
.................... { |
|
|
2425 |
.................... float32 y, res, r, y2; |
|
|
2426 |
.................... #if defined(__PCD__) |
|
|
2427 |
.................... unsigned int8 data1,data2; |
|
|
2428 |
.................... #endif |
|
|
2429 |
.................... signed int8 n; |
|
|
2430 |
.................... #ifdef _ERRNO |
|
|
2431 |
.................... if(x <0) |
|
|
2432 |
.................... { |
|
|
2433 |
.................... errno=EDOM; |
|
|
2434 |
.................... } |
|
|
2435 |
.................... if(x ==0) |
|
|
2436 |
.................... { |
|
|
2437 |
.................... errno=ERANGE; |
|
|
2438 |
.................... return(0); |
|
|
2439 |
.................... } |
|
|
2440 |
.................... #endif |
|
|
2441 |
.................... y = x; |
|
|
2442 |
.................... |
|
|
2443 |
.................... if (y != 1.0) |
|
|
2444 |
.................... { |
|
|
2445 |
.................... #if !defined(__PCD__) |
|
|
2446 |
.................... *((unsigned int8 *)(&y)) = 0x7E; |
|
|
2447 |
.................... #endif |
|
|
2448 |
.................... |
|
|
2449 |
.................... #if defined(__PCD__) // Takes care of IEEE format |
|
|
2450 |
.................... data2 = *(((unsigned int8 *)(&y))+3); |
|
|
2451 |
.................... *(((unsigned int8 *)(&y))+3) = 0x3F; |
|
|
2452 |
.................... data1 = *(((unsigned int8 *)(&y))+2); |
|
|
2453 |
.................... bit_clear(data1,7); |
|
|
2454 |
.................... *(((unsigned int8 *)(&y))+2) = data1; |
|
|
2455 |
.................... if(bit_test(data2,7)) |
|
|
2456 |
.................... bit_set(*(((unsigned int8 *)(&y))+3),7); |
|
|
2457 |
.................... #endif |
|
|
2458 |
.................... |
|
|
2459 |
.................... y = (y - 1.0)/(y + 1.0); |
|
|
2460 |
.................... |
|
|
2461 |
.................... y2=y*y; |
|
|
2462 |
.................... |
|
|
2463 |
.................... res = pl[0]*y2 + pl[1]; |
|
|
2464 |
.................... res = res*y2 + pl[2]; |
|
|
2465 |
.................... res = res*y2 + pl[3]; |
|
|
2466 |
.................... |
|
|
2467 |
.................... r = ql[0]*y2 + ql[1]; |
|
|
2468 |
.................... r = r*y2 + ql[2]; |
|
|
2469 |
.................... r = r*y2 + ql[3]; |
|
|
2470 |
.................... |
|
|
2471 |
.................... res = y*res/r; |
|
|
2472 |
.................... #if !defined(__PCD__) |
|
|
2473 |
.................... n = *((unsigned int8 *)(&x)) - 0x7E; |
|
|
2474 |
.................... #endif |
|
|
2475 |
.................... #if defined(__PCD__) |
|
|
2476 |
.................... data1 = *(((unsigned int8 *)(&x)+3)); |
|
|
2477 |
.................... rotate_left(&data1,1); |
|
|
2478 |
.................... data2 = *(((unsigned int8 *)(&x)+2)); |
|
|
2479 |
.................... if(bit_test (data2,7)) |
|
|
2480 |
.................... bit_set(data1,0); |
|
|
2481 |
.................... n = data1 - 0x7E; |
|
|
2482 |
.................... #endif |
|
|
2483 |
.................... |
|
|
2484 |
.................... if (n<0) |
|
|
2485 |
.................... r = -(float32)-n; |
|
|
2486 |
.................... else |
|
|
2487 |
.................... r = (float32)n; |
|
|
2488 |
.................... |
|
|
2489 |
.................... res += r*LN2; |
|
|
2490 |
.................... } |
|
|
2491 |
.................... |
|
|
2492 |
.................... else |
|
|
2493 |
.................... res = 0.0; |
|
|
2494 |
.................... |
|
|
2495 |
.................... return(res); |
|
|
2496 |
.................... } |
|
|
2497 |
.................... |
|
|
2498 |
.................... //Overloaded function for log() for PCD |
|
|
2499 |
.................... // Overloaded function log() for data type - Float48 |
|
|
2500 |
.................... #if defined(__PCD__) |
|
|
2501 |
.................... float48 log(float48 x) |
|
|
2502 |
.................... { |
|
|
2503 |
.................... float48 y, res, r, y2; |
|
|
2504 |
.................... unsigned int8 data1,data2; |
|
|
2505 |
.................... signed int8 n; |
|
|
2506 |
.................... #ifdef _ERRNO |
|
|
2507 |
.................... if(x <0) |
|
|
2508 |
.................... { |
|
|
2509 |
.................... errno=EDOM; |
|
|
2510 |
.................... } |
|
|
2511 |
.................... if(x ==0) |
|
|
2512 |
.................... { |
|
|
2513 |
.................... errno=ERANGE; |
|
|
2514 |
.................... return(0); |
|
|
2515 |
.................... } |
|
|
2516 |
.................... #endif |
|
|
2517 |
.................... y = x; |
|
|
2518 |
.................... |
|
|
2519 |
.................... if (y != 1.0) |
|
|
2520 |
.................... { |
|
|
2521 |
.................... |
|
|
2522 |
.................... #if !defined(__PCD__) |
|
|
2523 |
.................... *((unsigned int8 *)(&y)) = 0x7E; |
|
|
2524 |
.................... #endif |
|
|
2525 |
.................... data2 = *(((unsigned int8 *)(&y))+5); |
|
|
2526 |
.................... *(((unsigned int8 *)(&y))+5) = 0x3F; |
|
|
2527 |
.................... data1 = *(((unsigned int8 *)(&y))+4); |
|
|
2528 |
.................... bit_clear(data1,7); |
|
|
2529 |
.................... *(((unsigned int8 *)(&y))+4) = data1; |
|
|
2530 |
.................... |
|
|
2531 |
.................... if(bit_test(data2,7)) |
|
|
2532 |
.................... bit_set(*(((unsigned int8 *)(&y))+4),7); |
|
|
2533 |
.................... y = (y - 1.0)/(y + 1.0); |
|
|
2534 |
.................... |
|
|
2535 |
.................... y2=y*y; |
|
|
2536 |
.................... |
|
|
2537 |
.................... res = pl[0]*y2 + pl[1]; |
|
|
2538 |
.................... res = res*y2 + pl[2]; |
|
|
2539 |
.................... res = res*y2 + pl[3]; |
|
|
2540 |
.................... |
|
|
2541 |
.................... r = ql[0]*y2 + ql[1]; |
|
|
2542 |
.................... r = r*y2 + ql[2]; |
|
|
2543 |
.................... r = r*y2 + ql[3]; |
|
|
2544 |
.................... |
|
|
2545 |
.................... res = y*res/r; |
|
|
2546 |
.................... |
|
|
2547 |
.................... data1 = *(((unsigned int8 *)(&x)+5)); |
|
|
2548 |
.................... rotate_left(&data1,1); |
|
|
2549 |
.................... data2 = *(((unsigned int8 *)(&x)+4)); |
|
|
2550 |
.................... if(bit_test (data2,7)) |
|
|
2551 |
.................... bit_set(data1,0); |
|
|
2552 |
.................... |
|
|
2553 |
.................... n = data1 - 0x7E; |
|
|
2554 |
.................... |
|
|
2555 |
.................... if (n<0) |
|
|
2556 |
.................... r = -(float48)-n; |
|
|
2557 |
.................... else |
|
|
2558 |
.................... r = (float48)n; |
|
|
2559 |
.................... |
|
|
2560 |
.................... res += r*LN2; |
|
|
2561 |
.................... } |
|
|
2562 |
.................... |
|
|
2563 |
.................... else |
|
|
2564 |
.................... res = 0.0; |
|
|
2565 |
.................... |
|
|
2566 |
.................... return(res); |
|
|
2567 |
.................... } |
|
|
2568 |
.................... |
|
|
2569 |
.................... // Overloaded function log() for data type - Float48 |
|
|
2570 |
.................... #if defined(__PCD__) |
|
|
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}; |
|
|
2573 |
.................... #endif |
|
|
2574 |
.................... float64 log(float64 x) |
|
|
2575 |
.................... { |
|
|
2576 |
.................... float64 y, res, r, y2; |
|
|
2577 |
.................... unsigned int16 data1,data2; |
|
|
2578 |
.................... unsigned int16 *p; |
|
|
2579 |
.................... signed int16 n; |
|
|
2580 |
.................... #ifdef _ERRNO |
|
|
2581 |
.................... if(x <0) |
|
|
2582 |
.................... { |
|
|
2583 |
.................... errno=EDOM; |
|
|
2584 |
.................... } |
|
|
2585 |
.................... if(x ==0) |
|
|
2586 |
.................... { |
|
|
2587 |
.................... errno=ERANGE; |
|
|
2588 |
.................... return(0); |
|
|
2589 |
.................... } |
|
|
2590 |
.................... #endif |
|
|
2591 |
.................... y = x; |
|
|
2592 |
.................... |
|
|
2593 |
.................... if (y != 1.0) |
|
|
2594 |
.................... { |
|
|
2595 |
.................... #if !defined(__PCD__) |
|
|
2596 |
.................... *((unsigned int8 *)(&y)) = 0x7E; |
|
|
2597 |
.................... #endif |
|
|
2598 |
.................... p= (((unsigned int16 *)(&y))+3); |
|
|
2599 |
.................... data1 = *p; |
|
|
2600 |
.................... data2 = *p; |
|
|
2601 |
.................... data1 = 0x3FE; |
|
|
2602 |
.................... data1 = data1 <<4; |
|
|
2603 |
.................... if(bit_test (data2,15)) |
|
|
2604 |
.................... bit_set(data1,15); |
|
|
2605 |
.................... data2 = data2 & 0x000F; |
|
|
2606 |
.................... data1 ^=data2; |
|
|
2607 |
.................... |
|
|
2608 |
.................... *p = data1; |
|
|
2609 |
.................... |
|
|
2610 |
.................... y = (y - 1.0)/(y + 1.0); |
|
|
2611 |
.................... |
|
|
2612 |
.................... y2=y*y; |
|
|
2613 |
.................... |
|
|
2614 |
.................... res = pl_64[0]*y2 + pl_64[1]; |
|
|
2615 |
.................... res = res*y2 + pl_64[2]; |
|
|
2616 |
.................... res = res*y2 + pl_64[3]; |
|
|
2617 |
.................... |
|
|
2618 |
.................... r = ql_64[0]*y2 + ql_64[1]; |
|
|
2619 |
.................... r = r*y2 + ql_64[2]; |
|
|
2620 |
.................... r = r*y2 + ql_64[3]; |
|
|
2621 |
.................... |
|
|
2622 |
.................... res = y*res/r; |
|
|
2623 |
.................... |
|
|
2624 |
.................... p= (((unsigned int16 *)(&x))+3); |
|
|
2625 |
.................... data1 = *p; |
|
|
2626 |
.................... bit_clear(data1,15); |
|
|
2627 |
.................... data1 = data1 >>4; |
|
|
2628 |
.................... n = data1 - 0x3FE; |
|
|
2629 |
.................... |
|
|
2630 |
.................... |
|
|
2631 |
.................... if (n<0) |
|
|
2632 |
.................... r = -(float64)-n; |
|
|
2633 |
.................... else |
|
|
2634 |
.................... r = (float64)n; |
|
|
2635 |
.................... |
|
|
2636 |
.................... res += r*LN2; |
|
|
2637 |
.................... } |
|
|
2638 |
.................... |
|
|
2639 |
.................... else |
|
|
2640 |
.................... res = 0.0; |
|
|
2641 |
.................... |
|
|
2642 |
.................... return(res); |
|
|
2643 |
.................... } |
|
|
2644 |
.................... #endif |
|
|
2645 |
.................... |
|
|
2646 |
.................... |
|
|
2647 |
.................... #define LN10 2.3025850929940456 |
|
|
2648 |
.................... |
|
|
2649 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
2650 |
.................... // float log10(float x) |
|
|
2651 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
2652 |
.................... // Description : returns the the log base 10 of x |
|
|
2653 |
.................... // Date : N/A |
|
|
2654 |
.................... // |
|
|
2655 |
.................... float32 log10(float32 x) |
|
|
2656 |
.................... { |
|
|
2657 |
.................... float32 r; |
|
|
2658 |
.................... |
|
|
2659 |
.................... r = log(x); |
|
|
2660 |
.................... r = r/LN10; |
|
|
2661 |
.................... return(r); |
|
|
2662 |
.................... } |
|
|
2663 |
.................... |
|
|
2664 |
.................... //Overloaded functions for log10() for PCD |
|
|
2665 |
.................... // Overloaded function log10() for data type - Float48 |
|
|
2666 |
.................... #if defined(__PCD__) |
|
|
2667 |
.................... float48 log10(float48 x) |
|
|
2668 |
.................... { |
|
|
2669 |
.................... float48 r; |
|
|
2670 |
.................... |
|
|
2671 |
.................... r = log(x); |
|
|
2672 |
.................... r = r/LN10; |
|
|
2673 |
.................... return(r); |
|
|
2674 |
.................... } |
|
|
2675 |
.................... |
|
|
2676 |
.................... // Overloaded function log10() for data type - Float64 |
|
|
2677 |
.................... float64 log10(float64 x) |
|
|
2678 |
.................... { |
|
|
2679 |
.................... float64 r; |
|
|
2680 |
.................... |
|
|
2681 |
.................... r = log(x); |
|
|
2682 |
.................... r = r/LN10; |
|
|
2683 |
.................... return(r); |
|
|
2684 |
.................... } |
|
|
2685 |
.................... #endif |
|
|
2686 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
2687 |
.................... // float modf(float x) |
|
|
2688 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
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 |
|
|
2691 |
.................... // as a float in the object pointed to by the iptr |
|
|
2692 |
.................... // Returns : returns the signed fractional part of value. |
|
|
2693 |
.................... // Date : N/A |
|
|
2694 |
.................... // |
|
|
2695 |
.................... |
|
|
2696 |
.................... float32 modf(float32 value,float32 *iptr) |
|
|
2697 |
.................... { |
|
|
2698 |
.................... *iptr=(value < 0.0)? ceil(value): floor(value); |
|
|
2699 |
.................... return(value - *iptr); |
|
|
2700 |
.................... } |
|
|
2701 |
.................... //Overloaded functions for modf() for PCD |
|
|
2702 |
.................... // Overloaded function modf() for data type - Float48 |
|
|
2703 |
.................... #if defined(__PCD__) |
|
|
2704 |
.................... float48 modf(float48 value,float48 *iptr) |
|
|
2705 |
.................... { |
|
|
2706 |
.................... *iptr=(value < 0.0)? ceil(value): floor(value); |
|
|
2707 |
.................... return(value - *iptr); |
|
|
2708 |
.................... } |
|
|
2709 |
.................... // Overloaded function modf() for data type - Float64 |
|
|
2710 |
.................... float64 modf(float64 value,float64 *iptr) |
|
|
2711 |
.................... { |
|
|
2712 |
.................... *iptr=(value < 0.0)? ceil(value): floor(value); |
|
|
2713 |
.................... return(value - *iptr); |
|
|
2714 |
.................... } |
|
|
2715 |
.................... #endif |
|
|
2716 |
.................... |
|
|
2717 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
2718 |
.................... // float pwr(float x,float y) |
|
|
2719 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
2720 |
.................... // Description : returns the value (x^y) |
|
|
2721 |
.................... // Date : N/A |
|
|
2722 |
.................... // Note : 0 is returned when the function will generate an imaginary number |
|
|
2723 |
.................... // |
|
|
2724 |
.................... float32 pwr(float32 x,float32 y) |
|
|
2725 |
.................... { |
|
|
2726 |
.................... if(0 > x && fmod(y, 1) == 0) { |
|
|
2727 |
.................... if(fmod(y, 2) == 0) { |
|
|
2728 |
.................... return (exp(log(-x) * y)); |
|
|
2729 |
.................... } else { |
|
|
2730 |
.................... return (-exp(log(-x) * y)); |
|
|
2731 |
.................... } |
|
|
2732 |
.................... } else if(0 > x && fmod(y, 1) != 0) { |
|
|
2733 |
.................... return 0; |
|
|
2734 |
.................... } else { |
|
|
2735 |
.................... if(x != 0 || 0 >= y) { |
|
|
2736 |
.................... return (exp(log(x) * y)); |
|
|
2737 |
.................... } |
|
|
2738 |
.................... } |
|
|
2739 |
.................... } |
|
|
2740 |
.................... //Overloaded functions for pwr() for PCD |
|
|
2741 |
.................... // Overloaded function pwr() for data type - Float48 |
|
|
2742 |
.................... #if defined(__PCD__) |
|
|
2743 |
.................... float48 pwr(float48 x,float48 y) |
|
|
2744 |
.................... { |
|
|
2745 |
.................... if(0 > x && fmod(y, 1) == 0) { |
|
|
2746 |
.................... if(fmod(y, 2) == 0) { |
|
|
2747 |
.................... return (exp(log(-x) * y)); |
|
|
2748 |
.................... } else { |
|
|
2749 |
.................... return (-exp(log(-x) * y)); |
|
|
2750 |
.................... } |
|
|
2751 |
.................... } else if(0 > x && fmod(y, 1) != 0) { |
|
|
2752 |
.................... return 0; |
|
|
2753 |
.................... } else { |
|
|
2754 |
.................... if(x != 0 || 0 >= y) { |
|
|
2755 |
.................... return (exp(log(x) * y)); |
|
|
2756 |
.................... } |
|
|
2757 |
.................... } |
|
|
2758 |
.................... } |
|
|
2759 |
.................... // Overloaded function pwr() for data type - Float64 |
|
|
2760 |
.................... float64 pwr(float64 x,float64 y) |
|
|
2761 |
.................... { |
|
|
2762 |
.................... if(0 > x && fmod(y, 1) == 0) { |
|
|
2763 |
.................... if(fmod(y, 2) == 0) { |
|
|
2764 |
.................... return (exp(log(-x) * y)); |
|
|
2765 |
.................... } else { |
|
|
2766 |
.................... return (-exp(log(-x) * y)); |
|
|
2767 |
.................... } |
|
|
2768 |
.................... } else if(0 > x && fmod(y, 1) != 0) { |
|
|
2769 |
.................... return 0; |
|
|
2770 |
.................... } else { |
|
|
2771 |
.................... if(x != 0 || 0 >= y) { |
|
|
2772 |
.................... return (exp(log(x) * y)); |
|
|
2773 |
.................... } |
|
|
2774 |
.................... } |
|
|
2775 |
.................... } |
|
|
2776 |
.................... #endif |
|
|
2777 |
.................... |
|
|
2778 |
.................... //////////////////// Power functions //////////////////// |
|
|
2779 |
.................... |
|
|
2780 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
2781 |
.................... // float pow(float x,float y) |
|
|
2782 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
2783 |
.................... // Description : returns the value (x^y) |
|
|
2784 |
.................... // Date : N/A |
|
|
2785 |
.................... // Note : 0 is returned when the function will generate an imaginary number |
|
|
2786 |
.................... // |
|
|
2787 |
.................... float32 pow(float32 x,float32 y) |
|
|
2788 |
.................... { |
|
|
2789 |
.................... if(0 > x && fmod(y, 1) == 0) { |
|
|
2790 |
.................... if(fmod(y, 2) == 0) { |
|
|
2791 |
.................... return (exp(log(-x) * y)); |
|
|
2792 |
.................... } else { |
|
|
2793 |
.................... return (-exp(log(-x) * y)); |
|
|
2794 |
.................... } |
|
|
2795 |
.................... } else if(0 > x && fmod(y, 1) != 0) { |
|
|
2796 |
.................... return 0; |
|
|
2797 |
.................... } else { |
|
|
2798 |
.................... if(x != 0 || 0 >= y) { |
|
|
2799 |
.................... return (exp(log(x) * y)); |
|
|
2800 |
.................... } |
|
|
2801 |
.................... } |
|
|
2802 |
.................... } |
|
|
2803 |
.................... //Overloaded functions for pow() for PCD |
|
|
2804 |
.................... // Overloaded function for pow() data type - Float48 |
|
|
2805 |
.................... #if defined(__PCD__) |
|
|
2806 |
.................... float48 pow(float48 x,float48 y) |
|
|
2807 |
.................... { |
|
|
2808 |
.................... if(0 > x && fmod(y, 1) == 0) { |
|
|
2809 |
.................... if(fmod(y, 2) == 0) { |
|
|
2810 |
.................... return (exp(log(-x) * y)); |
|
|
2811 |
.................... } else { |
|
|
2812 |
.................... return (-exp(log(-x) * y)); |
|
|
2813 |
.................... } |
|
|
2814 |
.................... } else if(0 > x && fmod(y, 1) != 0) { |
|
|
2815 |
.................... return 0; |
|
|
2816 |
.................... } else { |
|
|
2817 |
.................... if(x != 0 || 0 >= y) { |
|
|
2818 |
.................... return (exp(log(x) * y)); |
|
|
2819 |
.................... } |
|
|
2820 |
.................... } |
|
|
2821 |
.................... } |
|
|
2822 |
.................... |
|
|
2823 |
.................... // Overloaded function pow() for data type - Float64 |
|
|
2824 |
.................... float64 pow(float64 x,float64 y) |
|
|
2825 |
.................... { |
|
|
2826 |
.................... if(0 > x && fmod(y, 1) == 0) { |
|
|
2827 |
.................... if(fmod(y, 2) == 0) { |
|
|
2828 |
.................... return (exp(log(-x) * y)); |
|
|
2829 |
.................... } else { |
|
|
2830 |
.................... return (-exp(log(-x) * y)); |
|
|
2831 |
.................... } |
|
|
2832 |
.................... } else if(0 > x && fmod(y, 1) != 0) { |
|
|
2833 |
.................... return 0; |
|
|
2834 |
.................... } else { |
|
|
2835 |
.................... if(x != 0 || 0 >= y) { |
|
|
2836 |
.................... return (exp(log(x) * y)); |
|
|
2837 |
.................... } |
|
|
2838 |
.................... } |
|
|
2839 |
.................... } |
|
|
2840 |
.................... #endif |
|
|
2841 |
.................... |
|
|
2842 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
2843 |
.................... // float sqrt(float x) |
|
|
2844 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
2845 |
.................... // Description : returns the square root of x |
|
|
2846 |
.................... // Date : N/A |
|
|
2847 |
.................... // |
|
|
2848 |
.................... float32 sqrt(float32 x) |
|
|
2849 |
.................... { |
|
|
2850 |
.................... float32 y, res; |
|
|
2851 |
.................... #if defined(__PCD__) |
|
|
2852 |
.................... unsigned int16 data1,data2; |
|
|
2853 |
.................... #endif |
|
|
2854 |
.................... BYTE *p; |
|
|
2855 |
.................... |
|
|
2856 |
.................... #ifdef _ERRNO |
|
|
2857 |
.................... if(x < 0) |
|
|
2858 |
.................... { |
|
|
2859 |
.................... errno=EDOM; |
|
|
2860 |
.................... } |
|
|
2861 |
.................... #endif |
|
|
2862 |
.................... |
|
|
2863 |
.................... if( x<=0.0) |
|
|
2864 |
.................... return(0.0); |
|
|
2865 |
.................... |
|
|
2866 |
.................... y=x; |
|
|
2867 |
.................... |
|
|
2868 |
.................... #if !defined(__PCD__) |
|
|
2869 |
.................... p=&y; |
|
|
2870 |
.................... (*p)=(BYTE)((((unsigned int16)(*p)) + 127) >> 1); |
|
|
2871 |
.................... #endif |
|
|
2872 |
.................... |
|
|
2873 |
.................... #if defined(__PCD__) |
|
|
2874 |
.................... p = (((unsigned int8 *)(&y))+3); |
|
|
2875 |
.................... data1 = *(((unsigned int8 *)(&y))+3); |
|
|
2876 |
.................... data2 = *(((unsigned int8 *)(&y))+2); |
|
|
2877 |
.................... rotate_left(&data1,1); |
|
|
2878 |
.................... if(bit_test(data2,7)) |
|
|
2879 |
.................... bit_set(data1,0); |
|
|
2880 |
.................... data1 = ((data1+127) >>1); |
|
|
2881 |
.................... bit_clear(data2,7); |
|
|
2882 |
.................... if(bit_test(data1,0)) |
|
|
2883 |
.................... bit_set(data2,7); |
|
|
2884 |
.................... data1 = data1 >>1; |
|
|
2885 |
.................... *(((unsigned int8 *)(&y))+3) = data1; |
|
|
2886 |
.................... *(((unsigned int8 *)(&y))+2) = data2; |
|
|
2887 |
.................... |
|
|
2888 |
.................... #endif |
|
|
2889 |
.................... |
|
|
2890 |
.................... do { |
|
|
2891 |
.................... res=y; |
|
|
2892 |
.................... y+=(x/y); |
|
|
2893 |
.................... |
|
|
2894 |
.................... #if !defined(__PCD__) |
|
|
2895 |
.................... (*p)--; |
|
|
2896 |
.................... #endif |
|
|
2897 |
.................... |
|
|
2898 |
.................... #if defined(__PCD__) |
|
|
2899 |
.................... data1 = *(((unsigned int8 *)(&y))+3); |
|
|
2900 |
.................... data2 = *(((unsigned int8 *)(&y))+2); |
|
|
2901 |
.................... rotate_left(&data1,1); |
|
|
2902 |
.................... if(bit_test(data2,7)) |
|
|
2903 |
.................... bit_set(data1,0); |
|
|
2904 |
.................... data1--; |
|
|
2905 |
.................... bit_clear(data2,7); |
|
|
2906 |
.................... if(bit_test(data1,0)) |
|
|
2907 |
.................... bit_set(data2,7); |
|
|
2908 |
.................... data1 = data1 >>1; |
|
|
2909 |
.................... *(((unsigned int8 *)(&y))+3) = data1; |
|
|
2910 |
.................... *(((unsigned int8 *)(&y))+2) = data2; |
|
|
2911 |
.................... |
|
|
2912 |
.................... #endif |
|
|
2913 |
.................... } while(res != y); |
|
|
2914 |
.................... |
|
|
2915 |
.................... return(res); |
|
|
2916 |
.................... } |
|
|
2917 |
.................... //Overloaded functions for sqrt() for PCD |
|
|
2918 |
.................... // Overloaded function sqrt() for data type - Float48 |
|
|
2919 |
.................... #if defined(__PCD__) |
|
|
2920 |
.................... float48 sqrt(float48 x) |
|
|
2921 |
.................... { |
|
|
2922 |
.................... float48 y, res; |
|
|
2923 |
.................... unsigned int16 data1,data2; |
|
|
2924 |
.................... BYTE *p; |
|
|
2925 |
.................... |
|
|
2926 |
.................... #ifdef _ERRNO |
|
|
2927 |
.................... if(x < 0) |
|
|
2928 |
.................... { |
|
|
2929 |
.................... errno=EDOM; |
|
|
2930 |
.................... } |
|
|
2931 |
.................... #endif |
|
|
2932 |
.................... |
|
|
2933 |
.................... if( x<=0.0) |
|
|
2934 |
.................... return(0.0); |
|
|
2935 |
.................... |
|
|
2936 |
.................... y=x; |
|
|
2937 |
.................... |
|
|
2938 |
.................... #if !defined(__PCD__) |
|
|
2939 |
.................... p=&y; |
|
|
2940 |
.................... (*p)=(BYTE)((((unsigned int16)(*p)) + 127) >> 1); |
|
|
2941 |
.................... #endif |
|
|
2942 |
.................... |
|
|
2943 |
.................... #if defined(__PCD__) |
|
|
2944 |
.................... p = (((unsigned int8 *)(&y))+5); |
|
|
2945 |
.................... data1 = *(((unsigned int8 *)(&y))+5); |
|
|
2946 |
.................... data2 = *(((unsigned int8 *)(&y))+4); |
|
|
2947 |
.................... rotate_left(&data1,1); |
|
|
2948 |
.................... if(bit_test(data2,7)) |
|
|
2949 |
.................... bit_set(data1,0); |
|
|
2950 |
.................... data1 = ((data1+127) >>1); |
|
|
2951 |
.................... bit_clear(data2,7); |
|
|
2952 |
.................... if(bit_test(data1,0)) |
|
|
2953 |
.................... bit_set(data2,7); |
|
|
2954 |
.................... data1 = data1 >>1; |
|
|
2955 |
.................... *(((unsigned int8 *)(&y))+5) = data1; |
|
|
2956 |
.................... *(((unsigned int8 *)(&y))+4) = data2; |
|
|
2957 |
.................... |
|
|
2958 |
.................... #endif |
|
|
2959 |
.................... |
|
|
2960 |
.................... do { |
|
|
2961 |
.................... res=y; |
|
|
2962 |
.................... y+=(x/y); |
|
|
2963 |
.................... |
|
|
2964 |
.................... #if !defined(__PCD__) |
|
|
2965 |
.................... (*p)--; |
|
|
2966 |
.................... #endif |
|
|
2967 |
.................... |
|
|
2968 |
.................... data1 = *(((unsigned int8 *)(&y))+5); |
|
|
2969 |
.................... data2 = *(((unsigned int8 *)(&y))+4); |
|
|
2970 |
.................... rotate_left(&data1,1); |
|
|
2971 |
.................... if(bit_test(data2,7)) |
|
|
2972 |
.................... bit_set(data1,0); |
|
|
2973 |
.................... data1--; |
|
|
2974 |
.................... bit_clear(data2,7); |
|
|
2975 |
.................... if(bit_test(data1,0)) |
|
|
2976 |
.................... bit_set(data2,7); |
|
|
2977 |
.................... data1 = data1 >>1; |
|
|
2978 |
.................... *(((unsigned int8 *)(&y))+5) = data1; |
|
|
2979 |
.................... *(((unsigned int8 *)(&y))+4) = data2; |
|
|
2980 |
.................... |
|
|
2981 |
.................... } while(res != y); |
|
|
2982 |
.................... |
|
|
2983 |
.................... return(res); |
|
|
2984 |
.................... } |
|
|
2985 |
.................... |
|
|
2986 |
.................... // Overloaded function sqrt() for data type - Float64 |
|
|
2987 |
.................... float64 sqrt(float64 x) |
|
|
2988 |
.................... { |
|
|
2989 |
.................... float64 y, res; |
|
|
2990 |
.................... unsigned int16 *p; |
|
|
2991 |
.................... unsigned int16 temp1,temp2; |
|
|
2992 |
.................... |
|
|
2993 |
.................... #ifdef _ERRNO |
|
|
2994 |
.................... if(x < 0) |
|
|
2995 |
.................... { |
|
|
2996 |
.................... errno=EDOM; |
|
|
2997 |
.................... } |
|
|
2998 |
.................... #endif |
|
|
2999 |
.................... |
|
|
3000 |
.................... if( x<=0.0) |
|
|
3001 |
.................... return(0.0); |
|
|
3002 |
.................... |
|
|
3003 |
.................... y=x; |
|
|
3004 |
.................... p= (((unsigned int16 *)(&y))+3); |
|
|
3005 |
.................... temp1 = *p; |
|
|
3006 |
.................... temp2 = *p; |
|
|
3007 |
.................... bit_clear(temp1,15); |
|
|
3008 |
.................... temp1 = (temp1>>4)+1023; |
|
|
3009 |
.................... temp1 = temp1 >> 1; |
|
|
3010 |
.................... temp1 = (temp1<<4) & 0xFFF0; |
|
|
3011 |
.................... if(bit_test(temp2,15)) |
|
|
3012 |
.................... bit_set(temp1,15); |
|
|
3013 |
.................... temp2 = temp2 & 0x000F; |
|
|
3014 |
.................... temp1 ^= temp2; |
|
|
3015 |
.................... |
|
|
3016 |
.................... (*p) = temp1; |
|
|
3017 |
.................... |
|
|
3018 |
.................... do { |
|
|
3019 |
.................... res=y; |
|
|
3020 |
.................... y+=(x/y); |
|
|
3021 |
.................... temp1 = *p; |
|
|
3022 |
.................... temp2 = *p; |
|
|
3023 |
.................... bit_clear(temp1,15); |
|
|
3024 |
.................... temp1 = (temp1>>4); |
|
|
3025 |
.................... temp1--; |
|
|
3026 |
.................... temp1 = (temp1<<4) & 0xFFF0; |
|
|
3027 |
.................... if(bit_test(temp2,15)) |
|
|
3028 |
.................... bit_set(temp1,15); |
|
|
3029 |
.................... temp2 = temp2 & 0x000F; |
|
|
3030 |
.................... temp1 ^= temp2; |
|
|
3031 |
.................... (*p) = temp1; |
|
|
3032 |
.................... |
|
|
3033 |
.................... } while(res != y); |
|
|
3034 |
.................... |
|
|
3035 |
.................... return(res); |
|
|
3036 |
.................... } |
|
|
3037 |
.................... #endif |
|
|
3038 |
.................... |
|
|
3039 |
.................... ////////////////////////////// Trig Functions ////////////////////////////// |
|
|
3040 |
.................... #ifdef PI_DIV_BY_TWO |
|
|
3041 |
.................... #undef PI_DIV_BY_TWO |
|
|
3042 |
.................... #endif |
|
|
3043 |
.................... #define PI_DIV_BY_TWO 1.5707963267948966 |
|
|
3044 |
.................... #ifdef TWOBYPI |
|
|
3045 |
.................... #undef TWOBYPI |
|
|
3046 |
.................... #define TWOBYPI 0.6366197723675813 |
|
|
3047 |
.................... #endif |
|
|
3048 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
3049 |
.................... // float cos(float x) |
|
|
3050 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
3051 |
.................... // Description : returns the cosine value of the angle x, which is in radian |
|
|
3052 |
.................... // Date : 9/20/2001 |
|
|
3053 |
.................... // |
|
|
3054 |
.................... float32 cos(float32 x) |
|
|
3055 |
.................... { |
|
|
3056 |
.................... float32 y, t, t2 = 1.0; |
|
|
3057 |
.................... unsigned int8 quad, i; |
|
|
3058 |
.................... float32 frac; |
|
|
3059 |
.................... float32 p[6] = { //by the series definition for cosine |
|
|
3060 |
.................... -0.5, // sum ( ( (-1)^n * x^2n )/(2n)! ) |
|
|
3061 |
.................... 0.04166666666667, |
|
|
3062 |
.................... -0.00138888888889, |
|
|
3063 |
.................... 0.00002480158730, |
|
|
3064 |
.................... -0.00000027557319, |
|
|
3065 |
.................... 0.00000000208767, |
|
|
3066 |
.................... //-0.00000000001147, |
|
|
3067 |
.................... // 0.00000000000005 |
|
|
3068 |
.................... }; |
|
|
3069 |
.................... |
|
|
3070 |
.................... if (x < 0) x = -x; // absolute value of input |
|
|
3071 |
.................... |
|
|
3072 |
.................... quad = (unsigned int8)(x / PI_DIV_BY_TWO); // quadrant |
|
|
3073 |
.................... frac = (x / PI_DIV_BY_TWO) - quad; // fractional part of input |
|
|
3074 |
.................... quad = quad % 4; // quadrant (0 to 3) |
|
|
3075 |
.................... |
|
|
3076 |
.................... if (quad == 0 || quad == 2) |
|
|
3077 |
.................... t = frac * PI_DIV_BY_TWO; |
|
|
3078 |
.................... else if (quad == 1) |
|
|
3079 |
.................... t = (1-frac) * PI_DIV_BY_TWO; |
|
|
3080 |
.................... else // should be 3 |
|
|
3081 |
.................... t = (frac-1) * PI_DIV_BY_TWO; |
|
|
3082 |
.................... |
|
|
3083 |
.................... y = 1.0; |
|
|
3084 |
.................... t = t * t; |
|
|
3085 |
.................... for (i = 0; i <= 5; i++) |
|
|
3086 |
.................... { |
|
|
3087 |
.................... t2 = t2 * t; |
|
|
3088 |
.................... y = y + p[i] * t2; |
|
|
3089 |
.................... } |
|
|
3090 |
.................... |
|
|
3091 |
.................... if (quad == 2 || quad == 1) |
|
|
3092 |
.................... y = -y; // correct sign |
|
|
3093 |
.................... |
|
|
3094 |
.................... return (y); |
|
|
3095 |
.................... } |
|
|
3096 |
.................... |
|
|
3097 |
.................... |
|
|
3098 |
.................... //Overloaded functions for cos() for PCD |
|
|
3099 |
.................... // Overloaded function cos() for data type - Float48 |
|
|
3100 |
.................... #if defined(__PCD__) |
|
|
3101 |
.................... float48 cos(float48 x) |
|
|
3102 |
.................... { |
|
|
3103 |
.................... float48 y, t, t2 = 1.0; |
|
|
3104 |
.................... unsigned int8 quad, i; |
|
|
3105 |
.................... float48 frac; |
|
|
3106 |
.................... float48 p[6] = { //by the series definition for cosine |
|
|
3107 |
.................... -0.5, // sum ( ( (-1)^n * x^2n )/(2n)! ) |
|
|
3108 |
.................... 0.04166666666667, |
|
|
3109 |
.................... -0.00138888888889, |
|
|
3110 |
.................... 0.00002480158730, |
|
|
3111 |
.................... -0.00000027557319, |
|
|
3112 |
.................... 0.00000000208767, |
|
|
3113 |
.................... //-0.00000000001147, |
|
|
3114 |
.................... // 0.00000000000005 |
|
|
3115 |
.................... }; |
|
|
3116 |
.................... |
|
|
3117 |
.................... if (x < 0) x = -x; // absolute value of input |
|
|
3118 |
.................... |
|
|
3119 |
.................... quad = (unsigned int8)(x / PI_DIV_BY_TWO); // quadrant |
|
|
3120 |
.................... frac = (x / PI_DIV_BY_TWO) - quad; // fractional part of input |
|
|
3121 |
.................... quad = quad % 4; // quadrant (0 to 3) |
|
|
3122 |
.................... |
|
|
3123 |
.................... if (quad == 0 || quad == 2) |
|
|
3124 |
.................... t = frac * PI_DIV_BY_TWO; |
|
|
3125 |
.................... else if (quad == 1) |
|
|
3126 |
.................... t = (1-frac) * PI_DIV_BY_TWO; |
|
|
3127 |
.................... else // should be 3 |
|
|
3128 |
.................... t = (frac-1) * PI_DIV_BY_TWO; |
|
|
3129 |
.................... |
|
|
3130 |
.................... y = 0.999999999781; |
|
|
3131 |
.................... t = t * t; |
|
|
3132 |
.................... for (i = 0; i <= 5; i++) |
|
|
3133 |
.................... { |
|
|
3134 |
.................... t2 = t2 * t; |
|
|
3135 |
.................... y = y + p[i] * t2; |
|
|
3136 |
.................... } |
|
|
3137 |
.................... |
|
|
3138 |
.................... if (quad == 2 || quad == 1) |
|
|
3139 |
.................... y = -y; // correct sign |
|
|
3140 |
.................... |
|
|
3141 |
.................... return (y); |
|
|
3142 |
.................... } |
|
|
3143 |
.................... |
|
|
3144 |
.................... // Overloaded function cos() for data type - Float48 |
|
|
3145 |
.................... float64 cos(float64 x) |
|
|
3146 |
.................... { |
|
|
3147 |
.................... float64 y, t, t2 = 1.0; |
|
|
3148 |
.................... unsigned int8 quad, i; |
|
|
3149 |
.................... float64 frac; |
|
|
3150 |
.................... float64 p[6] = { //by the series definition for cosine |
|
|
3151 |
.................... -0.5, // sum ( ( (-1)^n * x^2n )/(2n)! ) |
|
|
3152 |
.................... 0.04166666666667, |
|
|
3153 |
.................... -0.00138888888889, |
|
|
3154 |
.................... 0.00002480158730, |
|
|
3155 |
.................... -0.00000027557319, |
|
|
3156 |
.................... 0.00000000208767, |
|
|
3157 |
.................... //-0.00000000001147, |
|
|
3158 |
.................... // 0.00000000000005 |
|
|
3159 |
.................... }; |
|
|
3160 |
.................... |
|
|
3161 |
.................... if (x < 0) x = -x; // absolute value of input |
|
|
3162 |
.................... |
|
|
3163 |
.................... quad = (unsigned int8)(x / PI_DIV_BY_TWO); // quadrant |
|
|
3164 |
.................... frac = (x / PI_DIV_BY_TWO) - quad; // fractional part of input |
|
|
3165 |
.................... quad = quad % 4; // quadrant (0 to 3) |
|
|
3166 |
.................... |
|
|
3167 |
.................... if (quad == 0 || quad == 2) |
|
|
3168 |
.................... t = frac * PI_DIV_BY_TWO; |
|
|
3169 |
.................... else if (quad == 1) |
|
|
3170 |
.................... t = (1-frac) * PI_DIV_BY_TWO; |
|
|
3171 |
.................... else // should be 3 |
|
|
3172 |
.................... t = (frac-1) * PI_DIV_BY_TWO; |
|
|
3173 |
.................... |
|
|
3174 |
.................... y = 0.999999999781; |
|
|
3175 |
.................... t = t * t; |
|
|
3176 |
.................... for (i = 0; i <= 5; i++) |
|
|
3177 |
.................... { |
|
|
3178 |
.................... t2 = t2 * t; |
|
|
3179 |
.................... y = y + p[i] * t2; |
|
|
3180 |
.................... } |
|
|
3181 |
.................... |
|
|
3182 |
.................... if (quad == 2 || quad == 1) |
|
|
3183 |
.................... y = -y; // correct sign |
|
|
3184 |
.................... |
|
|
3185 |
.................... return (y); |
|
|
3186 |
.................... } |
|
|
3187 |
.................... |
|
|
3188 |
.................... #endif |
|
|
3189 |
.................... |
|
|
3190 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
3191 |
.................... // float sin(float x) |
|
|
3192 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
3193 |
.................... // Description : returns the sine value of the angle x, which is in radian |
|
|
3194 |
.................... // Date : 9/20/2001 |
|
|
3195 |
.................... // |
|
|
3196 |
.................... float32 sin(float32 x) |
|
|
3197 |
.................... { |
|
|
3198 |
.................... return cos(x - PI_DIV_BY_TWO); |
|
|
3199 |
.................... } |
|
|
3200 |
.................... |
|
|
3201 |
.................... //Overloaded functions for sin() for PCD |
|
|
3202 |
.................... // Overloaded function sin() for data type - Float48 |
|
|
3203 |
.................... #if defined(__PCD__) |
|
|
3204 |
.................... float48 sin(float48 x) |
|
|
3205 |
.................... { |
|
|
3206 |
.................... return cos(x - PI_DIV_BY_TWO); |
|
|
3207 |
.................... } |
|
|
3208 |
.................... |
|
|
3209 |
.................... // Overloaded function sin() for data type - Float48 |
|
|
3210 |
.................... float64 sin(float64 x) |
|
|
3211 |
.................... { |
|
|
3212 |
.................... return cos(x - PI_DIV_BY_TWO); |
|
|
3213 |
.................... } |
|
|
3214 |
.................... #endif |
|
|
3215 |
.................... |
|
|
3216 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
3217 |
.................... // float tan(float x) |
|
|
3218 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
3219 |
.................... // Description : returns the tangent value of the angle x, which is in radian |
|
|
3220 |
.................... // Date : 9/20/2001 |
|
|
3221 |
.................... // |
|
|
3222 |
.................... float32 tan(float32 x) |
|
|
3223 |
.................... { |
|
|
3224 |
.................... float32 c, s; |
|
|
3225 |
.................... |
|
|
3226 |
.................... c = cos(x); |
|
|
3227 |
.................... if (c == 0.0) |
|
|
3228 |
.................... return (1.0e+36); |
|
|
3229 |
.................... |
|
|
3230 |
.................... s = sin(x); |
|
|
3231 |
.................... return(s/c); |
|
|
3232 |
.................... } |
|
|
3233 |
.................... //Overloaded functions for tan() for PCD |
|
|
3234 |
.................... // Overloaded function tan() for data type - Float48 |
|
|
3235 |
.................... #if defined(__PCD__) |
|
|
3236 |
.................... float48 tan(float48 x) |
|
|
3237 |
.................... { |
|
|
3238 |
.................... float48 c, s; |
|
|
3239 |
.................... |
|
|
3240 |
.................... c = cos(x); |
|
|
3241 |
.................... if (c == 0.0) |
|
|
3242 |
.................... return (1.0e+36); |
|
|
3243 |
.................... |
|
|
3244 |
.................... s = sin(x); |
|
|
3245 |
.................... return(s/c); |
|
|
3246 |
.................... } |
|
|
3247 |
.................... |
|
|
3248 |
.................... // Overloaded function tan() for data type - Float48 |
|
|
3249 |
.................... float64 tan(float64 x) |
|
|
3250 |
.................... { |
|
|
3251 |
.................... float64 c, s; |
|
|
3252 |
.................... |
|
|
3253 |
.................... c = cos(x); |
|
|
3254 |
.................... if (c == 0.0) |
|
|
3255 |
.................... return (1.0e+36); |
|
|
3256 |
.................... |
|
|
3257 |
.................... s = sin(x); |
|
|
3258 |
.................... return(s/c); |
|
|
3259 |
.................... } |
|
|
3260 |
.................... #endif |
|
|
3261 |
.................... |
|
|
3262 |
.................... float32 const pas[3] = {0.49559947, -4.6145309, 5.6036290}; |
|
|
3263 |
.................... float32 const qas[3] = {1.0000000, -5.5484666, 5.6036290}; |
|
|
3264 |
.................... |
|
|
3265 |
.................... float32 ASIN_COS(float32 x, unsigned int8 n) |
|
|
3266 |
.................... { |
|
|
3267 |
.................... float32 y, res, r, y2; |
|
|
3268 |
.................... int1 s; |
|
|
3269 |
.................... #ifdef _ERRNO |
|
|
3270 |
.................... if(x <-1 || x > 1) |
|
|
3271 |
.................... { |
|
|
3272 |
.................... errno=EDOM; |
|
|
3273 |
.................... } |
|
|
3274 |
.................... #endif |
|
|
3275 |
.................... s = 0; |
|
|
3276 |
.................... y = x; |
|
|
3277 |
.................... |
|
|
3278 |
.................... if (x < 0) |
|
|
3279 |
.................... { |
|
|
3280 |
.................... s = 1; |
|
|
3281 |
.................... y = -y; |
|
|
3282 |
.................... } |
|
|
3283 |
.................... |
|
|
3284 |
.................... if (y > 0.5) |
|
|
3285 |
.................... { |
|
|
3286 |
.................... y = sqrt((1.0 - y)/2.0); |
|
|
3287 |
.................... n += 2; |
|
|
3288 |
.................... } |
|
|
3289 |
.................... |
|
|
3290 |
.................... y2=y*y; |
|
|
3291 |
.................... |
|
|
3292 |
.................... res = pas[0]*y2 + pas[1]; |
|
|
3293 |
.................... res = res*y2 + pas[2]; |
|
|
3294 |
.................... |
|
|
3295 |
.................... r = qas[0]*y2 + qas[1]; |
|
|
3296 |
.................... r = r*y2 + qas[2]; |
|
|
3297 |
.................... |
|
|
3298 |
.................... res = y*res/r; |
|
|
3299 |
.................... |
|
|
3300 |
.................... if (n & 2) // |x| > 0.5 |
|
|
3301 |
.................... res = PI_DIV_BY_TWO - 2.0*res; |
|
|
3302 |
.................... if (s) |
|
|
3303 |
.................... res = -res; |
|
|
3304 |
.................... if (n & 1) // take arccos |
|
|
3305 |
.................... res = PI_DIV_BY_TWO - res; |
|
|
3306 |
.................... |
|
|
3307 |
.................... return(res); |
|
|
3308 |
.................... } |
|
|
3309 |
.................... |
|
|
3310 |
.................... //Overloaded functions for ASIN_COS() for PCD |
|
|
3311 |
.................... // Overloaded function ASIN_COS() for data type - Float48 |
|
|
3312 |
.................... #if defined(__PCD__) |
|
|
3313 |
.................... float48 ASIN_COS(float48 x, unsigned int8 n) |
|
|
3314 |
.................... { |
|
|
3315 |
.................... float48 y, res, r, y2; |
|
|
3316 |
.................... int1 s; |
|
|
3317 |
.................... #ifdef _ERRNO |
|
|
3318 |
.................... if(x <-1 || x > 1) |
|
|
3319 |
.................... { |
|
|
3320 |
.................... errno=EDOM; |
|
|
3321 |
.................... } |
|
|
3322 |
.................... #endif |
|
|
3323 |
.................... s = 0; |
|
|
3324 |
.................... y = x; |
|
|
3325 |
.................... |
|
|
3326 |
.................... if (x < 0) |
|
|
3327 |
.................... { |
|
|
3328 |
.................... s = 1; |
|
|
3329 |
.................... y = -y; |
|
|
3330 |
.................... } |
|
|
3331 |
.................... |
|
|
3332 |
.................... if (y > 0.5) |
|
|
3333 |
.................... { |
|
|
3334 |
.................... y = sqrt((1.0 - y)/2.0); |
|
|
3335 |
.................... n += 2; |
|
|
3336 |
.................... } |
|
|
3337 |
.................... |
|
|
3338 |
.................... y2=y*y; |
|
|
3339 |
.................... |
|
|
3340 |
.................... res = pas[0]*y2 + pas[1]; |
|
|
3341 |
.................... res = res*y2 + pas[2]; |
|
|
3342 |
.................... |
|
|
3343 |
.................... r = qas[0]*y2 + qas[1]; |
|
|
3344 |
.................... r = r*y2 + qas[2]; |
|
|
3345 |
.................... |
|
|
3346 |
.................... res = y*res/r; |
|
|
3347 |
.................... |
|
|
3348 |
.................... if (n & 2) // |x| > 0.5 |
|
|
3349 |
.................... res = PI_DIV_BY_TWO - 2.0*res; |
|
|
3350 |
.................... if (s) |
|
|
3351 |
.................... res = -res; |
|
|
3352 |
.................... if (n & 1) // take arccos |
|
|
3353 |
.................... res = PI_DIV_BY_TWO - res; |
|
|
3354 |
.................... |
|
|
3355 |
.................... return(res); |
|
|
3356 |
.................... } |
|
|
3357 |
.................... |
|
|
3358 |
.................... // Overloaded function ASIN_COS() for data type - Float64 |
|
|
3359 |
.................... float64 ASIN_COS(float64 x, unsigned int8 n) |
|
|
3360 |
.................... { |
|
|
3361 |
.................... float64 y, res, r, y2; |
|
|
3362 |
.................... int1 s; |
|
|
3363 |
.................... #ifdef _ERRNO |
|
|
3364 |
.................... if(x <-1 || x > 1) |
|
|
3365 |
.................... { |
|
|
3366 |
.................... errno=EDOM; |
|
|
3367 |
.................... } |
|
|
3368 |
.................... #endif |
|
|
3369 |
.................... s = 0; |
|
|
3370 |
.................... y = x; |
|
|
3371 |
.................... |
|
|
3372 |
.................... if (x < 0) |
|
|
3373 |
.................... { |
|
|
3374 |
.................... s = 1; |
|
|
3375 |
.................... y = -y; |
|
|
3376 |
.................... } |
|
|
3377 |
.................... |
|
|
3378 |
.................... if (y > 0.5) |
|
|
3379 |
.................... { |
|
|
3380 |
.................... y = sqrt((1.0 - y)/2.0); |
|
|
3381 |
.................... n += 2; |
|
|
3382 |
.................... } |
|
|
3383 |
.................... |
|
|
3384 |
.................... y2=y*y; |
|
|
3385 |
.................... |
|
|
3386 |
.................... res = pas[0]*y2 + pas[1]; |
|
|
3387 |
.................... res = res*y2 + pas[2]; |
|
|
3388 |
.................... |
|
|
3389 |
.................... r = qas[0]*y2 + qas[1]; |
|
|
3390 |
.................... r = r*y2 + qas[2]; |
|
|
3391 |
.................... |
|
|
3392 |
.................... res = y*res/r; |
|
|
3393 |
.................... |
|
|
3394 |
.................... if (n & 2) // |x| > 0.5 |
|
|
3395 |
.................... res = PI_DIV_BY_TWO - 2.0*res; |
|
|
3396 |
.................... if (s) |
|
|
3397 |
.................... res = -res; |
|
|
3398 |
.................... if (n & 1) // take arccos |
|
|
3399 |
.................... res = PI_DIV_BY_TWO - res; |
|
|
3400 |
.................... |
|
|
3401 |
.................... return(res); |
|
|
3402 |
.................... } |
|
|
3403 |
.................... #endif |
|
|
3404 |
.................... |
|
|
3405 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
3406 |
.................... // float asin(float x) |
|
|
3407 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
3408 |
.................... // Description : returns the arcsine value of the value x. |
|
|
3409 |
.................... // Date : N/A |
|
|
3410 |
.................... // |
|
|
3411 |
.................... float32 asin(float32 x) |
|
|
3412 |
.................... { |
|
|
3413 |
.................... float32 r; |
|
|
3414 |
.................... |
|
|
3415 |
.................... r = ASIN_COS(x, 0); |
|
|
3416 |
.................... return(r); |
|
|
3417 |
.................... } |
|
|
3418 |
.................... //Overloaded functions for asin() for PCD |
|
|
3419 |
.................... // Overloaded function asin() for data type - Float48 |
|
|
3420 |
.................... #if defined(__PCD__) |
|
|
3421 |
.................... float48 asin(float48 x) |
|
|
3422 |
.................... { |
|
|
3423 |
.................... float48 r; |
|
|
3424 |
.................... |
|
|
3425 |
.................... r = ASIN_COS(x, 0); |
|
|
3426 |
.................... return(r); |
|
|
3427 |
.................... } |
|
|
3428 |
.................... |
|
|
3429 |
.................... // Overloaded function asin() for data type - Float64 |
|
|
3430 |
.................... float64 asin(float64 x) |
|
|
3431 |
.................... { |
|
|
3432 |
.................... float64 r; |
|
|
3433 |
.................... |
|
|
3434 |
.................... r = ASIN_COS(x, 0); |
|
|
3435 |
.................... return(r); |
|
|
3436 |
.................... } |
|
|
3437 |
.................... #endif |
|
|
3438 |
.................... |
|
|
3439 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
3440 |
.................... // float acos(float x) |
|
|
3441 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
3442 |
.................... // Description : returns the arccosine value of the value x. |
|
|
3443 |
.................... // Date : N/A |
|
|
3444 |
.................... // |
|
|
3445 |
.................... float32 acos(float32 x) |
|
|
3446 |
.................... { |
|
|
3447 |
.................... float32 r; |
|
|
3448 |
.................... |
|
|
3449 |
.................... r = ASIN_COS(x, 1); |
|
|
3450 |
.................... return(r); |
|
|
3451 |
.................... } |
|
|
3452 |
.................... //Overloaded functions for acos() for PCD |
|
|
3453 |
.................... // Overloaded function acos() for data type - Float48 |
|
|
3454 |
.................... #if defined(__PCD__) |
|
|
3455 |
.................... float48 acos(float48 x) |
|
|
3456 |
.................... { |
|
|
3457 |
.................... float48 r; |
|
|
3458 |
.................... |
|
|
3459 |
.................... r = ASIN_COS(x, 1); |
|
|
3460 |
.................... return(r); |
|
|
3461 |
.................... } |
|
|
3462 |
.................... |
|
|
3463 |
.................... // Overloaded function acos() for data type - Float64 |
|
|
3464 |
.................... float64 acos(float64 x) |
|
|
3465 |
.................... { |
|
|
3466 |
.................... float64 r; |
|
|
3467 |
.................... |
|
|
3468 |
.................... r = ASIN_COS(x, 1); |
|
|
3469 |
.................... return(r); |
|
|
3470 |
.................... } |
|
|
3471 |
.................... #endif |
|
|
3472 |
.................... |
|
|
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}; |
|
|
3475 |
.................... |
|
|
3476 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
3477 |
.................... // float atan(float x) |
|
|
3478 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
3479 |
.................... // Description : returns the arctangent value of the value x. |
|
|
3480 |
.................... // Date : N/A |
|
|
3481 |
.................... // |
|
|
3482 |
.................... float32 atan(float32 x) |
|
|
3483 |
.................... { |
|
|
3484 |
.................... float32 y, res, r; |
|
|
3485 |
.................... int1 s, flag; |
|
|
3486 |
.................... |
|
|
3487 |
.................... s = 0; |
|
|
3488 |
.................... flag = 0; |
|
|
3489 |
.................... y = x; |
|
|
3490 |
.................... |
|
|
3491 |
.................... if (x < 0) |
|
|
3492 |
.................... { |
|
|
3493 |
.................... s = 1; |
|
|
3494 |
.................... y = -y; |
|
|
3495 |
.................... } |
|
|
3496 |
.................... |
|
|
3497 |
.................... if (y > 1.0) |
|
|
3498 |
.................... { |
|
|
3499 |
.................... y = 1.0/y; |
|
|
3500 |
.................... flag = 1; |
|
|
3501 |
.................... } |
|
|
3502 |
.................... |
|
|
3503 |
.................... res = pat[0]*y*y + pat[1]; |
|
|
3504 |
.................... res = res*y*y + pat[2]; |
|
|
3505 |
.................... res = res*y*y + pat[3]; |
|
|
3506 |
.................... |
|
|
3507 |
.................... r = qat[0]*y*y + qat[1]; |
|
|
3508 |
.................... r = r*y*y + qat[2]; |
|
|
3509 |
.................... r = r*y*y + qat[3]; |
|
|
3510 |
.................... |
|
|
3511 |
.................... res = y*res/r; |
|
|
3512 |
.................... |
|
|
3513 |
.................... |
|
|
3514 |
.................... if (flag) // for |x| > 1 |
|
|
3515 |
.................... res = PI_DIV_BY_TWO - res; |
|
|
3516 |
.................... if (s) |
|
|
3517 |
.................... res = -res; |
|
|
3518 |
.................... |
|
|
3519 |
.................... return(res); |
|
|
3520 |
.................... } |
|
|
3521 |
.................... //Overloaded functions for atan() for PCD |
|
|
3522 |
.................... // Overloaded function atan() for data type - Float48 |
|
|
3523 |
.................... #if defined(__PCD__) |
|
|
3524 |
.................... float48 atan(float48 x) |
|
|
3525 |
.................... { |
|
|
3526 |
.................... float48 y, res, r; |
|
|
3527 |
.................... int1 s, flag; |
|
|
3528 |
.................... |
|
|
3529 |
.................... s = 0; |
|
|
3530 |
.................... flag = 0; |
|
|
3531 |
.................... y = x; |
|
|
3532 |
.................... |
|
|
3533 |
.................... if (x < 0) |
|
|
3534 |
.................... { |
|
|
3535 |
.................... s = 1; |
|
|
3536 |
.................... y = -y; |
|
|
3537 |
.................... } |
|
|
3538 |
.................... |
|
|
3539 |
.................... if (y > 1.0) |
|
|
3540 |
.................... { |
|
|
3541 |
.................... y = 1.0/y; |
|
|
3542 |
.................... flag = 1; |
|
|
3543 |
.................... } |
|
|
3544 |
.................... |
|
|
3545 |
.................... res = pat[0]*y*y + pat[1]; |
|
|
3546 |
.................... res = res*y*y + pat[2]; |
|
|
3547 |
.................... res = res*y*y + pat[3]; |
|
|
3548 |
.................... |
|
|
3549 |
.................... r = qat[0]*y*y + qat[1]; |
|
|
3550 |
.................... r = r*y*y + qat[2]; |
|
|
3551 |
.................... r = r*y*y + qat[3]; |
|
|
3552 |
.................... |
|
|
3553 |
.................... res = y*res/r; |
|
|
3554 |
.................... |
|
|
3555 |
.................... |
|
|
3556 |
.................... if (flag) // for |x| > 1 |
|
|
3557 |
.................... res = PI_DIV_BY_TWO - res; |
|
|
3558 |
.................... if (s) |
|
|
3559 |
.................... res = -res; |
|
|
3560 |
.................... |
|
|
3561 |
.................... return(res); |
|
|
3562 |
.................... } |
|
|
3563 |
.................... |
|
|
3564 |
.................... // Overloaded function atan() for data type - Float64 |
|
|
3565 |
.................... float64 atan(float64 x) |
|
|
3566 |
.................... { |
|
|
3567 |
.................... float64 y, res, r; |
|
|
3568 |
.................... int1 s, flag; |
|
|
3569 |
.................... |
|
|
3570 |
.................... s = 0; |
|
|
3571 |
.................... flag = 0; |
|
|
3572 |
.................... y = x; |
|
|
3573 |
.................... |
|
|
3574 |
.................... if (x < 0) |
|
|
3575 |
.................... { |
|
|
3576 |
.................... s = 1; |
|
|
3577 |
.................... y = -y; |
|
|
3578 |
.................... } |
|
|
3579 |
.................... |
|
|
3580 |
.................... if (y > 1.0) |
|
|
3581 |
.................... { |
|
|
3582 |
.................... y = 1.0/y; |
|
|
3583 |
.................... flag = 1; |
|
|
3584 |
.................... } |
|
|
3585 |
.................... |
|
|
3586 |
.................... res = pat[0]*y*y + pat[1]; |
|
|
3587 |
.................... res = res*y*y + pat[2]; |
|
|
3588 |
.................... res = res*y*y + pat[3]; |
|
|
3589 |
.................... |
|
|
3590 |
.................... r = qat[0]*y*y + qat[1]; |
|
|
3591 |
.................... r = r*y*y + qat[2]; |
|
|
3592 |
.................... r = r*y*y + qat[3]; |
|
|
3593 |
.................... |
|
|
3594 |
.................... res = y*res/r; |
|
|
3595 |
.................... |
|
|
3596 |
.................... |
|
|
3597 |
.................... if (flag) // for |x| > 1 |
|
|
3598 |
.................... res = PI_DIV_BY_TWO - res; |
|
|
3599 |
.................... if (s) |
|
|
3600 |
.................... res = -res; |
|
|
3601 |
.................... |
|
|
3602 |
.................... return(res); |
|
|
3603 |
.................... } |
|
|
3604 |
.................... #endif |
|
|
3605 |
.................... |
|
|
3606 |
.................... ///////////////////////////////////////////////////////////////////////////// |
|
|
3607 |
.................... // float atan2(float y, float x) |
|
|
3608 |
.................... ///////////////////////////////////////////////////////////////////////////// |
|
|
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 |
|
|
3611 |
.................... // Returns : returns the arc tangent of y/x. |
|
|
3612 |
.................... // Date : N/A |
|
|
3613 |
.................... // |
|
|
3614 |
.................... |
|
|
3615 |
.................... float32 atan2(float32 y,float32 x) |
|
|
3616 |
.................... { |
|
|
3617 |
.................... float32 z; |
|
|
3618 |
.................... int1 sign; |
|
|
3619 |
.................... unsigned int8 quad; |
|
|
3620 |
.................... sign=0; |
|
|
3621 |
.................... quad=0; //quadrant |
|
|
3622 |
.................... quad=((y<=0.0)?((x<=0.0)?3:4):((x<0.0)?2:1)); |
|
|
3623 |
.................... if(y<0.0) |
|
|
3624 |
.................... { |
|
|
3625 |
.................... sign=1; |
|
|
3626 |
.................... y=-y; |
|
|
3627 |
.................... } |
|
|
3628 |
.................... if(x<0.0) |
|
|
3629 |
.................... { |
|
|
3630 |
.................... x=-x; |
|
|
3631 |
.................... } |
|
|
3632 |
.................... if (x==0.0) |
|
|
3633 |
.................... { |
|
|
3634 |
.................... if(y==0.0) |
|
|
3635 |
.................... { |
|
|
3636 |
.................... #ifdef _ERRNO |
|
|
3637 |
.................... { |
|
|
3638 |
.................... errno=EDOM; |
|
|
3639 |
.................... } |
|
|
3640 |
.................... #endif |
|
|
3641 |
.................... } |
|
|
3642 |
.................... else |
|
|
3643 |
.................... { |
|
|
3644 |
.................... if(sign) |
|
|
3645 |
.................... { |
|
|
3646 |
.................... return (-(PI_DIV_BY_TWO)); |
|
|
3647 |
.................... } |
|
|
3648 |
.................... else |
|
|
3649 |
.................... { |
|
|
3650 |
.................... return (PI_DIV_BY_TWO); |
|
|
3651 |
.................... } |
|
|
3652 |
.................... } |
|
|
3653 |
.................... } |
|
|
3654 |
.................... else |
|
|
3655 |
.................... { |
|
|
3656 |
.................... z=y/x; |
|
|
3657 |
.................... switch(quad) |
|
|
3658 |
.................... { |
|
|
3659 |
.................... case 1: |
|
|
3660 |
.................... { |
|
|
3661 |
.................... return atan(z); |
|
|
3662 |
.................... break; |
|
|
3663 |
.................... } |
|
|
3664 |
.................... case 2: |
|
|
3665 |
.................... { |
|
|
3666 |
.................... // return (atan(z)+PI_DIV_BY_TWO); //2L3122 |
|
|
3667 |
.................... return (PI-atan(z)); |
|
|
3668 |
.................... break; |
|
|
3669 |
.................... } |
|
|
3670 |
.................... case 3: |
|
|
3671 |
.................... { |
|
|
3672 |
.................... return (atan(z)-PI); |
|
|
3673 |
.................... break; |
|
|
3674 |
.................... } |
|
|
3675 |
.................... case 4: |
|
|
3676 |
.................... { |
|
|
3677 |
.................... return (-atan(z)); |
|
|
3678 |
.................... break; |
|
|
3679 |
.................... } |
|
|
3680 |
.................... } |
|
|
3681 |
.................... } |
|
|
3682 |
.................... } |
|
|
3683 |
.................... |
|
|
3684 |
.................... //Overloaded functions for atan2() for PCD |
|
|
3685 |
.................... // Overloaded function atan2() for data type - Float48 |
|
|
3686 |
.................... #if defined(__PCD__) |
|
|
3687 |
.................... float48 atan2(float48 y,float48 x) |
|
|
3688 |
.................... { |
|
|
3689 |
.................... float48 z; |
|
|
3690 |
.................... int1 sign; |
|
|
3691 |
.................... unsigned int8 quad; |
|
|
3692 |
.................... sign=0; |
|
|
3693 |
.................... quad=0; //quadrant |
|
|
3694 |
.................... quad=((y<=0.0)?((x<=0.0)?3:4):((x<0.0)?2:1)); |
|
|
3695 |
.................... if(y<0.0) |
|
|
3696 |
.................... { |
|
|
3697 |
.................... sign=1; |
|
|
3698 |
.................... y=-y; |
|
|
3699 |
.................... } |
|
|
3700 |
.................... if(x<0.0) |
|
|
3701 |
.................... { |
|
|
3702 |
.................... x=-x; |
|
|
3703 |
.................... } |
|
|
3704 |
.................... if (x==0.0) |
|
|
3705 |
.................... { |
|
|
3706 |
.................... if(y==0.0) |
|
|
3707 |
.................... { |
|
|
3708 |
.................... #ifdef _ERRNO |
|
|
3709 |
.................... { |
|
|
3710 |
.................... errno=EDOM; |
|
|
3711 |
.................... } |
|
|
3712 |
.................... #endif |
|
|
3713 |
.................... } |
|
|
3714 |
.................... else |
|
|
3715 |
.................... { |
|
|
3716 |
.................... if(sign) |
|
|
3717 |
.................... { |
|
|
3718 |
.................... return (-(PI_DIV_BY_TWO)); |
|
|
3719 |
.................... } |
|
|
3720 |
.................... else |
|
|
3721 |
.................... { |
|
|
3722 |
.................... return (PI_DIV_BY_TWO); |
|
|
3723 |
.................... } |
|
|
3724 |
.................... } |
|
|
3725 |
.................... } |
|
|
3726 |
.................... else |
|
|
3727 |
.................... { |
|
|
3728 |
.................... z=y/x; |
|
|
3729 |
.................... switch(quad) |
|
|
3730 |
.................... { |
|
|
3731 |
.................... case 1: |
|
|
3732 |
.................... { |
|
|
3733 |
.................... return atan(z); |
|
|
3734 |
.................... break; |
|
|
3735 |
.................... } |
|
|
3736 |
.................... case 2: |
|
|
3737 |
.................... { |
|
|
3738 |
.................... // return (atan(z)+PI_DIV_BY_TWO); //2L3122 |
|
|
3739 |
.................... return (PI-atan(z)); |
|
|
3740 |
.................... break; |
|
|
3741 |
.................... } |
|
|
3742 |
.................... case 3: |
|
|
3743 |
.................... { |
|
|
3744 |
.................... return (atan(z)-PI); |
|
|
3745 |
.................... break; |
|
|
3746 |
.................... } |
|
|
3747 |
.................... case 4: |
|
|
3748 |
.................... { |
|
|
3749 |
.................... return (-atan(z)); |
|
|
3750 |
.................... break; |
|
|
3751 |
.................... } |
|
|
3752 |
.................... } |
|
|
3753 |
.................... } |
|
|
3754 |
.................... } |
|
|
3755 |
.................... |
|
|
3756 |
.................... // Overloaded function atan2() for data type - Float64 |
|
|
3757 |
.................... float64 atan2(float64 y,float64 x) |
|
|
3758 |
.................... { |
|
|
3759 |
.................... float64 z; |
|
|
3760 |
.................... int1 sign; |
|
|
3761 |
.................... unsigned int8 quad; |
|
|
3762 |
.................... sign=0; |
|
|
3763 |
.................... quad=0; //quadrant |
|
|
3764 |
.................... quad=((y<=0.0)?((x<=0.0)?3:4):((x<0.0)?2:1)); |
|
|
3765 |
.................... if(y<0.0) |
|
|
3766 |
.................... { |
|
|
3767 |
.................... sign=1; |
|
|
3768 |
.................... y=-y; |
|
|
3769 |
.................... } |
|
|
3770 |
.................... if(x<0.0) |
|
|
3771 |
.................... { |
|
|
3772 |
.................... x=-x; |
|
|
3773 |
.................... } |
|
|
3774 |
.................... if (x==0.0) |
|
|
3775 |
.................... { |
|
|
3776 |
.................... if(y==0.0) |
|
|
3777 |
.................... { |
|
|
3778 |
.................... #ifdef _ERRNO |
|
|
3779 |
.................... { |
|
|
3780 |
.................... errno=EDOM; |
|
|
3781 |
.................... } |
|
|
3782 |
.................... #endif |
|
|
3783 |
.................... } |
|
|
3784 |
.................... else |
|
|
3785 |
.................... { |
|
|
3786 |
.................... if(sign) |
|
|
3787 |
.................... { |
|
|
3788 |
.................... return (-(PI_DIV_BY_TWO)); |
|
|
3789 |
.................... } |
|
|
3790 |
.................... else |
|
|
3791 |
.................... { |
|
|
3792 |
.................... return (PI_DIV_BY_TWO); |
|
|
3793 |
.................... } |
|
|
3794 |
.................... } |
|
|
3795 |
.................... } |
|
|
3796 |
.................... else |
|
|
3797 |
.................... { |
|
|
3798 |
.................... z=y/x; |
|
|
3799 |
.................... switch(quad) |
|
|
3800 |
.................... { |
|
|
3801 |
.................... case 1: |
|
|
3802 |
.................... { |
|
|
3803 |
.................... return atan(z); |
|
|
3804 |
.................... break; |
|
|
3805 |
.................... } |
|
|
3806 |
.................... case 2: |
|
|
3807 |
.................... { |
|
|
3808 |
.................... // return (atan(z)+PI_DIV_BY_TWO); //2L3122 |
|
|
3809 |
.................... return (PI-atan(z)); |
|
|
3810 |
.................... break; |
|
|
3811 |
.................... } |
|
|
3812 |
.................... case 3: |
|
|
3813 |
.................... { |
|
|
3814 |
.................... return (atan(z)-PI); |
|
|
3815 |
.................... break; |
|
|
3816 |
.................... } |
|
|
3817 |
.................... case 4: |
|
|
3818 |
.................... { |
|
|
3819 |
.................... return (-atan(z)); |
|
|
3820 |
.................... break; |
|
|
3821 |
.................... } |
|
|
3822 |
.................... } |
|
|
3823 |
.................... } |
|
|
3824 |
.................... } |
|
|
3825 |
.................... #endif |
|
|
3826 |
.................... |
|
|
3827 |
.................... //////////////////// Hyperbolic functions //////////////////// |
|
|
3828 |
.................... |
|
|
3829 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
3830 |
.................... // float cosh(float x) |
|
|
3831 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
3832 |
.................... // Description : Computes the hyperbolic cosine value of x |
|
|
3833 |
.................... // Returns : returns the hyperbolic cosine value of x |
|
|
3834 |
.................... // Date : N/A |
|
|
3835 |
.................... // |
|
|
3836 |
.................... |
|
|
3837 |
.................... float32 cosh(float32 x) |
|
|
3838 |
.................... { |
|
|
3839 |
.................... return ((exp(x)+exp(-x))/2); |
|
|
3840 |
.................... } |
|
|
3841 |
.................... //Overloaded functions for cosh() for PCD |
|
|
3842 |
.................... // Overloaded function cosh() for data type - Float48 |
|
|
3843 |
.................... #if defined(__PCD__) |
|
|
3844 |
.................... float48 cosh(float48 x) |
|
|
3845 |
.................... { |
|
|
3846 |
.................... return ((exp(x)+exp(-x))/2); |
|
|
3847 |
.................... } |
|
|
3848 |
.................... |
|
|
3849 |
.................... // Overloaded function cosh() for data type - Float64 |
|
|
3850 |
.................... float64 cosh(float64 x) |
|
|
3851 |
.................... { |
|
|
3852 |
.................... return ((exp(x)+exp(-x))/2); |
|
|
3853 |
.................... } |
|
|
3854 |
.................... #endif |
|
|
3855 |
.................... |
|
|
3856 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
3857 |
.................... // float sinh(float x) |
|
|
3858 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
3859 |
.................... // Description : Computes the hyperbolic sine value of x |
|
|
3860 |
.................... // Returns : returns the hyperbolic sine value of x |
|
|
3861 |
.................... // Date : N/A |
|
|
3862 |
.................... // |
|
|
3863 |
.................... |
|
|
3864 |
.................... float32 sinh(float32 x) |
|
|
3865 |
.................... { |
|
|
3866 |
.................... |
|
|
3867 |
.................... return ((exp(x) - exp(-x))/2); |
|
|
3868 |
.................... } |
|
|
3869 |
.................... //Overloaded functions for sinh() for PCD |
|
|
3870 |
.................... // Overloaded function sinh() for data type - Float48 |
|
|
3871 |
.................... #if defined(__PCD__) |
|
|
3872 |
.................... float48 sinh(float48 x) |
|
|
3873 |
.................... { |
|
|
3874 |
.................... |
|
|
3875 |
.................... return ((exp(x) - exp(-x))/2); |
|
|
3876 |
.................... } |
|
|
3877 |
.................... |
|
|
3878 |
.................... // Overloaded function sinh() for data type - Float48 |
|
|
3879 |
.................... float64 sinh(float64 x) |
|
|
3880 |
.................... { |
|
|
3881 |
.................... |
|
|
3882 |
.................... return ((exp(x) - exp(-x))/2); |
|
|
3883 |
.................... } |
|
|
3884 |
.................... #endif |
|
|
3885 |
.................... |
|
|
3886 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
3887 |
.................... // float tanh(float x) |
|
|
3888 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
3889 |
.................... // Description : Computes the hyperbolic tangent value of x |
|
|
3890 |
.................... // Returns : returns the hyperbolic tangent value of x |
|
|
3891 |
.................... // Date : N/A |
|
|
3892 |
.................... // |
|
|
3893 |
.................... |
|
|
3894 |
.................... float32 tanh(float32 x) |
|
|
3895 |
.................... { |
|
|
3896 |
.................... return(sinh(x)/cosh(x)); |
|
|
3897 |
.................... } |
|
|
3898 |
.................... //Overloaded functions for tanh() for PCD |
|
|
3899 |
.................... // Overloaded function tanh() for data type - Float48 |
|
|
3900 |
.................... #if defined(__PCD__) |
|
|
3901 |
.................... float48 tanh(float48 x) |
|
|
3902 |
.................... { |
|
|
3903 |
.................... return(sinh(x)/cosh(x)); |
|
|
3904 |
.................... } |
|
|
3905 |
.................... |
|
|
3906 |
.................... // Overloaded function tanh() for data type - Float64 |
|
|
3907 |
.................... float64 tanh(float64 x) |
|
|
3908 |
.................... { |
|
|
3909 |
.................... return(sinh(x)/cosh(x)); |
|
|
3910 |
.................... } |
|
|
3911 |
.................... #endif |
|
|
3912 |
.................... |
|
|
3913 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
3914 |
.................... // float frexp(float x, signed int *exp) |
|
|
3915 |
.................... //////////////////////////////////////////////////////////////////////////// |
|
|
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. |
|
|
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, |
|
|
3920 |
.................... // both parts of the result are zero. |
|
|
3921 |
.................... // Date : N/A |
|
|
3922 |
.................... // |
|
|
3923 |
.................... |
|
|
3924 |
.................... #define LOG2 .30102999566398119521 |
|
|
3925 |
.................... float32 frexp(float32 x, signed int8 *exp) |
|
|
3926 |
.................... { |
|
|
3927 |
.................... float32 res; |
|
|
3928 |
.................... int1 sign = 0; |
|
|
3929 |
.................... if(x == 0.0) |
|
|
3930 |
.................... { |
|
|
3931 |
.................... *exp=0; |
|
|
3932 |
.................... return (0.0); |
|
|
3933 |
.................... } |
|
|
3934 |
.................... if(x < 0.0) |
|
|
3935 |
.................... { |
|
|
3936 |
.................... x=-x; |
|
|
3937 |
.................... sign=1; |
|
|
3938 |
.................... } |
|
|
3939 |
.................... if (x > 1.0) |
|
|
3940 |
.................... { |
|
|
3941 |
.................... *exp=(ceil(log10(x)/LOG2)); |
|
|
3942 |
.................... res=x/(pow(2, *exp)); |
|
|
3943 |
.................... if (res == 1) |
|
|
3944 |
.................... { |
|
|
3945 |
.................... *exp=*exp+1; |
|
|
3946 |
.................... res=.5; |
|
|
3947 |
.................... } |
|
|
3948 |
.................... } |
|
|
3949 |
.................... else |
|
|
3950 |
.................... { |
|
|
3951 |
.................... if(x < 0.5) |
|
|
3952 |
.................... { |
|
|
3953 |
.................... *exp=-1; |
|
|
3954 |
.................... res=x*2; |
|
|
3955 |
.................... } |
|
|
3956 |
.................... else |
|
|
3957 |
.................... { |
|
|
3958 |
.................... *exp=0; |
|
|
3959 |
.................... res=x; |
|
|
3960 |
.................... } |
|
|
3961 |
.................... } |
|
|
3962 |
.................... if(sign) |
|
|
3963 |
.................... { |
|
|
3964 |
.................... res=-res; |
|
|
3965 |
.................... } |
|
|
3966 |
.................... return res; |
|
|
3967 |
.................... } |
|
|
3968 |
.................... |
|
|
3969 |
.................... //Overloaded functions for frexp() for PCD |
|
|
3970 |
.................... // Overloaded function frexp() for data type - Float48 |
|
|
3971 |
.................... #if defined(__PCD__) |
|
|
3972 |
.................... float48 frexp(float48 x, signed int8 *exp) |
|
|
3973 |
.................... { |
|
|
3974 |
.................... float48 res; |
|
|
3975 |
.................... int1 sign = 0; |
|
|
3976 |
.................... if(x == 0.0) |
|
|
3977 |
.................... { |
|
|
3978 |
.................... *exp=0; |
|
|
3979 |
.................... return (0.0); |
|
|
3980 |
.................... } |
|
|
3981 |
.................... if(x < 0.0) |
|
|
3982 |
.................... { |
|
|
3983 |
.................... x=-x; |
|
|
3984 |
.................... sign=1; |
|
|
3985 |
.................... } |
|
|
3986 |
.................... if (x > 1.0) |
|
|
3987 |
.................... { |
|
|
3988 |
.................... *exp=(ceil(log10(x)/LOG2)); |
|
|
3989 |
.................... res=x/(pow(2, *exp)); |
|
|
3990 |
.................... if (res == 1) |
|
|
3991 |
.................... { |
|
|
3992 |
.................... *exp=*exp+1; |
|
|
3993 |
.................... res=.5; |
|
|
3994 |
.................... } |
|
|
3995 |
.................... } |
|
|
3996 |
.................... else |
|
|
3997 |
.................... { |
|
|
3998 |
.................... if(x < 0.5) |
|
|
3999 |
.................... { |
|
|
4000 |
.................... *exp=-1; |
|
|
4001 |
.................... res=x*2; |
|
|
4002 |
.................... } |
|
|
4003 |
.................... else |
|
|
4004 |
.................... { |
|
|
4005 |
.................... *exp=0; |
|
|
4006 |
.................... res=x; |
|
|
4007 |
.................... } |
|
|
4008 |
.................... } |
|
|
4009 |
.................... if(sign) |
|
|
4010 |
.................... { |
|
|
4011 |
.................... res=-res; |
|
|
4012 |
.................... } |
|
|
4013 |
.................... return res; |
|
|
4014 |
.................... } |
|
|
4015 |
.................... |
|
|
4016 |
.................... // Overloaded function frexp() for data type - Float64 |
|
|
4017 |
.................... float64 frexp(float64 x, signed int8 *exp) |
|
|
4018 |
.................... { |
|
|
4019 |
.................... float64 res; |
|
|
4020 |
.................... int1 sign = 0; |
|
|
4021 |
.................... if(x == 0.0) |
|
|
4022 |
.................... { |
|
|
4023 |
.................... *exp=0; |
|
|
4024 |
.................... return (0.0); |
|
|
4025 |
.................... } |
|
|
4026 |
.................... if(x < 0.0) |
|
|
4027 |
.................... { |
|
|
4028 |
.................... x=-x; |
|
|
4029 |
.................... sign=1; |
|
|
4030 |
.................... } |
|
|
4031 |
.................... if (x > 1.0) |
|
|
4032 |
.................... { |
|
|
4033 |
.................... *exp=(ceil(log10(x)/LOG2)); |
|
|
4034 |
.................... res=x/(pow(2, *exp)); |
|
|
4035 |
.................... if (res == 1) |
|
|
4036 |
.................... { |
|
|
4037 |
.................... *exp=*exp+1; |
|
|
4038 |
.................... res=.5; |
|
|
4039 |
.................... } |
|
|
4040 |
.................... } |
|
|
4041 |
.................... else |
|
|
4042 |
.................... { |
|
|
4043 |
.................... if(x < 0.5) |
|
|
4044 |
.................... { |
|
|
4045 |
.................... *exp=-1; |
|
|
4046 |
.................... res=x*2; |
|
|
4047 |
.................... } |
|
|
4048 |
.................... else |
|
|
4049 |
.................... { |
|
|
4050 |
.................... *exp=0; |
|
|
4051 |
.................... res=x; |
|
|
4052 |
.................... } |
|
|
4053 |
.................... } |
|
|
4054 |
.................... if(sign) |
|
|
4055 |
.................... { |
|
|
4056 |
.................... res=-res; |
|
|
4057 |
.................... } |
|
|
4058 |
.................... return res; |
|
|
4059 |
.................... } |
|
|
4060 |
.................... #endif |
|
|
4061 |
.................... |
|
|
4062 |
.................... ////////////////////////////////////////////////////////////////////////////// |
|
|
4063 |
.................... // float ldexp(float x, signed int *exp) |
|
|
4064 |
.................... ////////////////////////////////////////////////////////////////////////////// |
|
|
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. |
|
|
4067 |
.................... // Date : N/A |
|
|
4068 |
.................... // |
|
|
4069 |
.................... |
|
|
4070 |
.................... float32 ldexp(float32 value, signed int8 exp) |
|
|
4071 |
.................... { |
|
|
4072 |
.................... return (value * pow(2,exp)); |
|
|
4073 |
.................... } |
|
|
4074 |
.................... //Overloaded functions for ldexp() for PCD |
|
|
4075 |
.................... // Overloaded function ldexp() for data type - Float48 |
|
|
4076 |
.................... |
|
|
4077 |
.................... #if defined(__PCD__) |
|
|
4078 |
.................... float48 ldexp(float48 value, signed int8 exp) |
|
|
4079 |
.................... { |
|
|
4080 |
.................... return (value * pow(2,exp)); |
|
|
4081 |
.................... } |
|
|
4082 |
.................... // Overloaded function ldexp() for data type - Float64 |
|
|
4083 |
.................... float64 ldexp(float64 value, signed int8 exp) |
|
|
4084 |
.................... { |
|
|
4085 |
.................... return (value * pow(2,exp)); |
|
|
4086 |
.................... } |
|
|
4087 |
.................... #endif |
|
|
4088 |
.................... |
|
|
4089 |
.................... #endif |
|
|
4090 |
.................... |
|
|
4091 |
.................... |
3286 |
kaklik |
4092 |
.................... #define MPL3115_ADDR_R 0xC1 //addresa pro cteni |
|
|
4093 |
.................... #define MPL3115_ADDR_W 0xC0 |
3283 |
kakl |
4094 |
.................... |
3286 |
kaklik |
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 |
.................... |
|
|
4756 |
.................... |
3275 |
kaklik |
4757 |
.................... void main() |
|
|
4758 |
.................... { |
|
|
4759 |
* |
3286 |
kaklik |
4760 |
0CE5: CLRF 04 |
|
|
4761 |
0CE6: BCF 03.7 |
|
|
4762 |
0CE7: MOVLW 1F |
|
|
4763 |
0CE8: ANDWF 03,F |
|
|
4764 |
0CE9: MOVLW 71 |
|
|
4765 |
0CEA: BSF 03.5 |
|
|
4766 |
0CEB: MOVWF 0F |
|
|
4767 |
0CEC: MOVF 0F,W |
|
|
4768 |
0CED: BSF 03.6 |
|
|
4769 |
0CEE: BCF 07.3 |
|
|
4770 |
0CEF: MOVLW 0C |
|
|
4771 |
0CF0: BCF 03.6 |
|
|
4772 |
0CF1: MOVWF 19 |
|
|
4773 |
0CF2: MOVLW A2 |
|
|
4774 |
0CF3: MOVWF 18 |
|
|
4775 |
0CF4: MOVLW 90 |
|
|
4776 |
0CF5: BCF 03.5 |
|
|
4777 |
0CF6: MOVWF 18 |
|
|
4778 |
0CF7: BSF 03.5 |
|
|
4779 |
0CF8: BSF 03.6 |
|
|
4780 |
0CF9: MOVF 09,W |
|
|
4781 |
0CFA: ANDLW C0 |
|
|
4782 |
0CFB: MOVWF 09 |
|
|
4783 |
0CFC: BCF 03.6 |
|
|
4784 |
0CFD: BCF 1F.4 |
|
|
4785 |
0CFE: BCF 1F.5 |
|
|
4786 |
0CFF: MOVLW 00 |
|
|
4787 |
0D00: BSF 03.6 |
|
|
4788 |
0D01: MOVWF 08 |
|
|
4789 |
0D02: BCF 03.5 |
|
|
4790 |
0D03: CLRF 07 |
|
|
4791 |
0D04: CLRF 08 |
|
|
4792 |
0D05: CLRF 09 |
3275 |
kaklik |
4793 |
* |
3286 |
kaklik |
4794 |
0D0F: CLRF 3C |
|
|
4795 |
0D10: CLRF 3B |
|
|
4796 |
.................... float temp1, temp2, temp3, humidity, preasure; |
3275 |
kaklik |
4797 |
.................... int16 i=0; |
|
|
4798 |
.................... |
|
|
4799 |
.................... setup_adc_ports(NO_ANALOGS|VSS_VDD); |
3286 |
kaklik |
4800 |
0D11: BSF 03.5 |
|
|
4801 |
0D12: BSF 03.6 |
|
|
4802 |
0D13: MOVF 09,W |
|
|
4803 |
0D14: ANDLW C0 |
|
|
4804 |
0D15: MOVWF 09 |
|
|
4805 |
0D16: BCF 03.6 |
|
|
4806 |
0D17: BCF 1F.4 |
|
|
4807 |
0D18: BCF 1F.5 |
|
|
4808 |
0D19: MOVLW 00 |
|
|
4809 |
0D1A: BSF 03.6 |
|
|
4810 |
0D1B: MOVWF 08 |
3275 |
kaklik |
4811 |
.................... setup_adc(ADC_CLOCK_DIV_2); |
3286 |
kaklik |
4812 |
0D1C: BCF 03.5 |
|
|
4813 |
0D1D: BCF 03.6 |
|
|
4814 |
0D1E: BCF 1F.6 |
|
|
4815 |
0D1F: BCF 1F.7 |
|
|
4816 |
0D20: BSF 03.5 |
|
|
4817 |
0D21: BSF 1F.7 |
|
|
4818 |
0D22: BCF 03.5 |
|
|
4819 |
0D23: BSF 1F.0 |
3275 |
kaklik |
4820 |
.................... setup_spi(SPI_SS_DISABLED); |
3286 |
kaklik |
4821 |
0D24: BCF 14.5 |
|
|
4822 |
0D25: BCF 20.5 |
|
|
4823 |
0D26: MOVF 20,W |
|
|
4824 |
0D27: BSF 03.5 |
|
|
4825 |
0D28: MOVWF 07 |
|
|
4826 |
0D29: BCF 03.5 |
|
|
4827 |
0D2A: BSF 20.4 |
|
|
4828 |
0D2B: MOVF 20,W |
|
|
4829 |
0D2C: BSF 03.5 |
|
|
4830 |
0D2D: MOVWF 07 |
|
|
4831 |
0D2E: BCF 03.5 |
|
|
4832 |
0D2F: BCF 20.3 |
|
|
4833 |
0D30: MOVF 20,W |
|
|
4834 |
0D31: BSF 03.5 |
|
|
4835 |
0D32: MOVWF 07 |
|
|
4836 |
0D33: MOVLW 01 |
|
|
4837 |
0D34: BCF 03.5 |
|
|
4838 |
0D35: MOVWF 14 |
|
|
4839 |
0D36: MOVLW 00 |
|
|
4840 |
0D37: BSF 03.5 |
|
|
4841 |
0D38: MOVWF 14 |
3275 |
kaklik |
4842 |
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
3286 |
kaklik |
4843 |
0D39: MOVF 01,W |
|
|
4844 |
0D3A: ANDLW C7 |
|
|
4845 |
0D3B: IORLW 08 |
|
|
4846 |
0D3C: MOVWF 01 |
3275 |
kaklik |
4847 |
.................... setup_timer_1(T1_DISABLED); |
3286 |
kaklik |
4848 |
0D3D: BCF 03.5 |
|
|
4849 |
0D3E: CLRF 10 |
3275 |
kaklik |
4850 |
.................... setup_timer_2(T2_DISABLED,0,1); |
3286 |
kaklik |
4851 |
0D3F: MOVLW 00 |
|
|
4852 |
0D40: MOVWF 78 |
|
|
4853 |
0D41: MOVWF 12 |
|
|
4854 |
0D42: MOVLW 00 |
|
|
4855 |
0D43: BSF 03.5 |
|
|
4856 |
0D44: MOVWF 12 |
3275 |
kaklik |
4857 |
.................... setup_ccp1(CCP_OFF); |
3286 |
kaklik |
4858 |
0D45: BCF 03.5 |
|
|
4859 |
0D46: BSF 20.2 |
|
|
4860 |
0D47: MOVF 20,W |
|
|
4861 |
0D48: BSF 03.5 |
|
|
4862 |
0D49: MOVWF 07 |
|
|
4863 |
0D4A: BCF 03.5 |
|
|
4864 |
0D4B: CLRF 17 |
|
|
4865 |
0D4C: BSF 03.5 |
|
|
4866 |
0D4D: CLRF 1B |
|
|
4867 |
0D4E: CLRF 1C |
|
|
4868 |
0D4F: MOVLW 01 |
|
|
4869 |
0D50: MOVWF 1D |
3275 |
kaklik |
4870 |
.................... setup_comparator(NC_NC_NC_NC); // This device COMP currently not supported by the PICWizard |
3286 |
kaklik |
4871 |
0D51: BCF 03.5 |
|
|
4872 |
0D52: BSF 03.6 |
|
|
4873 |
0D53: CLRF 07 |
|
|
4874 |
0D54: CLRF 08 |
|
|
4875 |
0D55: CLRF 09 |
3275 |
kaklik |
4876 |
.................... setup_oscillator(OSC_8MHZ); |
3286 |
kaklik |
4877 |
0D56: MOVLW 71 |
|
|
4878 |
0D57: BSF 03.5 |
|
|
4879 |
0D58: BCF 03.6 |
|
|
4880 |
0D59: MOVWF 0F |
|
|
4881 |
0D5A: MOVF 0F,W |
3275 |
kaklik |
4882 |
.................... |
|
|
4883 |
.................... |
3283 |
kakl |
4884 |
.................... printf("GeoMet01A\r\n"); |
3286 |
kaklik |
4885 |
0D5B: MOVLW 0C |
|
|
4886 |
0D5C: BCF 03.5 |
|
|
4887 |
0D5D: BSF 03.6 |
|
|
4888 |
0D5E: MOVWF 0D |
|
|
4889 |
0D5F: MOVLW 00 |
|
|
4890 |
0D60: MOVWF 0F |
|
|
4891 |
0D61: BCF 0A.3 |
|
|
4892 |
0D62: BCF 03.6 |
|
|
4893 |
0D63: CALL 030 |
|
|
4894 |
0D64: BSF 0A.3 |
3275 |
kaklik |
4895 |
.................... printf("(c) Kaklik 2013\r\n"); |
3286 |
kaklik |
4896 |
0D65: MOVLW 12 |
|
|
4897 |
0D66: BSF 03.6 |
|
|
4898 |
0D67: MOVWF 0D |
|
|
4899 |
0D68: MOVLW 00 |
|
|
4900 |
0D69: MOVWF 0F |
|
|
4901 |
0D6A: BCF 0A.3 |
|
|
4902 |
0D6B: BCF 03.6 |
|
|
4903 |
0D6C: CALL 030 |
|
|
4904 |
0D6D: BSF 0A.3 |
3275 |
kaklik |
4905 |
.................... printf("www.mlab.cz\r\n"); |
3286 |
kaklik |
4906 |
0D6E: MOVLW 1B |
|
|
4907 |
0D6F: BSF 03.6 |
|
|
4908 |
0D70: MOVWF 0D |
|
|
4909 |
0D71: MOVLW 00 |
|
|
4910 |
0D72: MOVWF 0F |
|
|
4911 |
0D73: BCF 0A.3 |
|
|
4912 |
0D74: BCF 03.6 |
|
|
4913 |
0D75: CALL 030 |
|
|
4914 |
0D76: BSF 0A.3 |
3283 |
kakl |
4915 |
.................... |
|
|
4916 |
.................... // Init the HMC5883L. Set Mode register for |
|
|
4917 |
.................... // continuous measurements. |
|
|
4918 |
.................... hmc5883l_write_reg(HMC5883L_CFG_A_REG, 0x18); // no average, maximal update range |
3286 |
kaklik |
4919 |
0D77: CLRF 3D |
|
|
4920 |
0D78: MOVLW 18 |
|
|
4921 |
0D79: MOVWF 3E |
|
|
4922 |
0D7A: BCF 0A.3 |
|
|
4923 |
0D7B: CALL 0C2 |
|
|
4924 |
0D7C: BSF 0A.3 |
3283 |
kakl |
4925 |
.................... hmc5883l_write_reg(HMC5883L_CFG_B_REG, 0x00); // minimal range |
3286 |
kaklik |
4926 |
0D7D: MOVLW 01 |
|
|
4927 |
0D7E: MOVWF 3D |
|
|
4928 |
0D7F: CLRF 3E |
|
|
4929 |
0D80: BCF 0A.3 |
|
|
4930 |
0D81: CALL 0C2 |
|
|
4931 |
0D82: BSF 0A.3 |
3283 |
kakl |
4932 |
.................... hmc5883l_write_reg(HMC5883L_MODE_REG, 0x00); |
3286 |
kaklik |
4933 |
0D83: MOVLW 02 |
|
|
4934 |
0D84: MOVWF 3D |
|
|
4935 |
0D85: CLRF 3E |
|
|
4936 |
0D86: BCF 0A.3 |
|
|
4937 |
0D87: CALL 0C2 |
|
|
4938 |
0D88: BSF 0A.3 |
3275 |
kaklik |
4939 |
.................... |
|
|
4940 |
.................... lcd_init(); |
3286 |
kaklik |
4941 |
0D89: BCF 0A.3 |
|
|
4942 |
0D8A: CALL 1C8 |
|
|
4943 |
0D8B: BSF 0A.3 |
3275 |
kaklik |
4944 |
.................... lcd_putc("(c) Kaklik 2013"); |
3286 |
kaklik |
4945 |
0D8C: MOVLW 22 |
|
|
4946 |
0D8D: BSF 03.6 |
|
|
4947 |
0D8E: MOVWF 0D |
|
|
4948 |
0D8F: MOVLW 00 |
|
|
4949 |
0D90: MOVWF 0F |
|
|
4950 |
0D91: BCF 0A.3 |
|
|
4951 |
0D92: BCF 03.6 |
|
|
4952 |
0D93: CALL 23F |
|
|
4953 |
0D94: BSF 0A.3 |
3275 |
kaklik |
4954 |
.................... lcd_gotoxy(3,2); |
3286 |
kaklik |
4955 |
0D95: MOVLW 03 |
|
|
4956 |
0D96: MOVWF 4B |
|
|
4957 |
0D97: MOVLW 02 |
|
|
4958 |
0D98: MOVWF 4C |
|
|
4959 |
0D99: BCF 0A.3 |
|
|
4960 |
0D9A: CALL 200 |
|
|
4961 |
0D9B: BSF 0A.3 |
3275 |
kaklik |
4962 |
.................... lcd_putc("www.mlab.cz"); |
3286 |
kaklik |
4963 |
0D9C: MOVLW 2A |
|
|
4964 |
0D9D: BSF 03.6 |
|
|
4965 |
0D9E: MOVWF 0D |
|
|
4966 |
0D9F: MOVLW 00 |
|
|
4967 |
0DA0: MOVWF 0F |
|
|
4968 |
0DA1: BCF 0A.3 |
|
|
4969 |
0DA2: BCF 03.6 |
|
|
4970 |
0DA3: CALL 23F |
|
|
4971 |
0DA4: BSF 0A.3 |
3275 |
kaklik |
4972 |
.................... Delay_ms(2000); |
3286 |
kaklik |
4973 |
0DA5: MOVLW 08 |
|
|
4974 |
0DA6: MOVWF 3D |
|
|
4975 |
0DA7: MOVLW FA |
|
|
4976 |
0DA8: MOVWF 4B |
|
|
4977 |
0DA9: BCF 0A.3 |
|
|
4978 |
0DAA: CALL 0FB |
|
|
4979 |
0DAB: BSF 0A.3 |
|
|
4980 |
0DAC: DECFSZ 3D,F |
|
|
4981 |
0DAD: GOTO 5A7 |
3275 |
kaklik |
4982 |
.................... lcd_init(); |
3286 |
kaklik |
4983 |
0DAE: BCF 0A.3 |
|
|
4984 |
0DAF: CALL 1C8 |
|
|
4985 |
0DB0: BSF 0A.3 |
3275 |
kaklik |
4986 |
.................... |
|
|
4987 |
.................... while (TRUE) |
|
|
4988 |
.................... { |
|
|
4989 |
.................... lcd_gotoxy(1,1); |
3286 |
kaklik |
4990 |
0DB1: MOVLW 01 |
|
|
4991 |
0DB2: MOVWF 4B |
|
|
4992 |
0DB3: MOVWF 4C |
|
|
4993 |
0DB4: BCF 0A.3 |
|
|
4994 |
0DB5: CALL 200 |
|
|
4995 |
0DB6: BSF 0A.3 |
3275 |
kaklik |
4996 |
.................... temp1 = SHT25_get_temp(); |
3286 |
kaklik |
4997 |
0DB7: BCF 0A.3 |
|
|
4998 |
0DB8: GOTO 567 |
|
|
4999 |
0DB9: BSF 0A.3 |
|
|
5000 |
0DBA: MOVF 7A,W |
|
|
5001 |
0DBB: MOVWF 2A |
|
|
5002 |
0DBC: MOVF 79,W |
|
|
5003 |
0DBD: MOVWF 29 |
|
|
5004 |
0DBE: MOVF 78,W |
|
|
5005 |
0DBF: MOVWF 28 |
|
|
5006 |
0DC0: MOVF 77,W |
|
|
5007 |
0DC1: MOVWF 27 |
3275 |
kaklik |
5008 |
.................... humidity = SHT25_get_hum(); |
3286 |
kaklik |
5009 |
0DC2: BCF 0A.3 |
|
|
5010 |
0DC3: GOTO 636 |
|
|
5011 |
0DC4: BSF 0A.3 |
|
|
5012 |
0DC5: MOVF 7A,W |
|
|
5013 |
0DC6: MOVWF 36 |
|
|
5014 |
0DC7: MOVF 79,W |
|
|
5015 |
0DC8: MOVWF 35 |
|
|
5016 |
0DC9: MOVF 78,W |
|
|
5017 |
0DCA: MOVWF 34 |
|
|
5018 |
0DCB: MOVF 77,W |
|
|
5019 |
0DCC: MOVWF 33 |
3283 |
kakl |
5020 |
.................... temp2= LTS01_get_temp(); |
3286 |
kaklik |
5021 |
0DCD: BCF 0A.3 |
|
|
5022 |
0DCE: GOTO 6EC |
|
|
5023 |
0DCF: BSF 0A.3 |
|
|
5024 |
0DD0: MOVF 7A,W |
|
|
5025 |
0DD1: MOVWF 2E |
|
|
5026 |
0DD2: MOVF 79,W |
|
|
5027 |
0DD3: MOVWF 2D |
|
|
5028 |
0DD4: MOVF 78,W |
|
|
5029 |
0DD5: MOVWF 2C |
|
|
5030 |
0DD6: MOVF 77,W |
|
|
5031 |
0DD7: MOVWF 2B |
3283 |
kakl |
5032 |
.................... hmc5883l_read_data(); |
3286 |
kaklik |
5033 |
0DD8: GOTO 000 |
|
|
5034 |
.................... |
|
|
5035 |
.................... temp3=mpl3115_T(); |
|
|
5036 |
0DD9: GOTO 091 |
|
|
5037 |
0DDA: MOVF 7A,W |
|
|
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 |
|
|
5044 |
0DE1: MOVWF 2F |
|
|
5045 |
.................... preasure=mpl3115_P(); |
|
|
5046 |
0DE2: GOTO 0F3 |
|
|
5047 |
0DE3: MOVF 7A,W |
|
|
5048 |
0DE4: MOVWF 3A |
|
|
5049 |
0DE5: MOVF 79,W |
|
|
5050 |
0DE6: MOVWF 39 |
|
|
5051 |
0DE7: MOVF 78,W |
|
|
5052 |
0DE8: MOVWF 38 |
|
|
5053 |
0DE9: MOVF 77,W |
|
|
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); |
|
|
5059 |
0DEC: MOVLW 89 |
|
|
5060 |
0DED: MOVWF 04 |
|
|
5061 |
0DEE: MOVF 2A,W |
|
|
5062 |
0DEF: MOVWF 40 |
|
|
5063 |
0DF0: MOVF 29,W |
|
|
5064 |
0DF1: MOVWF 3F |
|
|
5065 |
0DF2: MOVF 28,W |
|
|
5066 |
0DF3: MOVWF 3E |
|
|
5067 |
0DF4: MOVF 27,W |
|
|
5068 |
0DF5: MOVWF 3D |
|
|
5069 |
0DF6: MOVLW 02 |
|
|
5070 |
0DF7: MOVWF 41 |
|
|
5071 |
0DF8: CALL 2CB |
|
|
5072 |
0DF9: MOVLW B2 |
|
|
5073 |
0DFA: MOVWF 4A |
|
|
5074 |
0DFB: BCF 0A.3 |
|
|
5075 |
0DFC: CALL 212 |
|
|
5076 |
0DFD: BSF 0A.3 |
|
|
5077 |
0DFE: MOVLW 43 |
|
|
5078 |
0DFF: MOVWF 4A |
|
|
5079 |
0E00: BCF 0A.3 |
|
|
5080 |
0E01: CALL 212 |
|
|
5081 |
0E02: BSF 0A.3 |
|
|
5082 |
0E03: MOVLW 20 |
|
|
5083 |
0E04: MOVWF 4A |
|
|
5084 |
0E05: BCF 0A.3 |
|
|
5085 |
0E06: CALL 212 |
|
|
5086 |
0E07: BSF 0A.3 |
|
|
5087 |
0E08: MOVLW 89 |
|
|
5088 |
0E09: MOVWF 04 |
|
|
5089 |
0E0A: MOVF 36,W |
|
|
5090 |
0E0B: MOVWF 40 |
|
|
5091 |
0E0C: MOVF 35,W |
|
|
5092 |
0E0D: MOVWF 3F |
|
|
5093 |
0E0E: MOVF 34,W |
|
|
5094 |
0E0F: MOVWF 3E |
|
|
5095 |
0E10: MOVF 33,W |
|
|
5096 |
0E11: MOVWF 3D |
|
|
5097 |
0E12: MOVLW 02 |
|
|
5098 |
0E13: MOVWF 41 |
|
|
5099 |
0E14: CALL 2CB |
|
|
5100 |
0E15: MOVLW 25 |
|
|
5101 |
0E16: MOVWF 4A |
|
|
5102 |
0E17: BCF 0A.3 |
|
|
5103 |
0E18: CALL 212 |
|
|
5104 |
0E19: BSF 0A.3 |
3283 |
kakl |
5105 |
.................... lcd_gotoxy(1,2); |
3286 |
kaklik |
5106 |
0E1A: MOVLW 01 |
|
|
5107 |
0E1B: MOVWF 4B |
|
|
5108 |
0E1C: MOVLW 02 |
|
|
5109 |
0E1D: MOVWF 4C |
|
|
5110 |
0E1E: BCF 0A.3 |
|
|
5111 |
0E1F: CALL 200 |
|
|
5112 |
0E20: BSF 0A.3 |
|
|
5113 |
.................... printf(lcd_putc,"%2.2f%cC %6.0fPa ",temp2, 0xb2, preasure); |
|
|
5114 |
0E21: MOVLW 89 |
|
|
5115 |
0E22: MOVWF 04 |
|
|
5116 |
0E23: MOVF 2E,W |
|
|
5117 |
0E24: MOVWF 40 |
|
|
5118 |
0E25: MOVF 2D,W |
|
|
5119 |
0E26: MOVWF 3F |
|
|
5120 |
0E27: MOVF 2C,W |
|
|
5121 |
0E28: MOVWF 3E |
|
|
5122 |
0E29: MOVF 2B,W |
|
|
5123 |
0E2A: MOVWF 3D |
|
|
5124 |
0E2B: MOVLW 02 |
|
|
5125 |
0E2C: MOVWF 41 |
|
|
5126 |
0E2D: CALL 2CB |
|
|
5127 |
0E2E: MOVLW B2 |
|
|
5128 |
0E2F: MOVWF 4A |
|
|
5129 |
0E30: BCF 0A.3 |
|
|
5130 |
0E31: CALL 212 |
|
|
5131 |
0E32: BSF 0A.3 |
|
|
5132 |
0E33: MOVLW 43 |
|
|
5133 |
0E34: MOVWF 4A |
|
|
5134 |
0E35: BCF 0A.3 |
|
|
5135 |
0E36: CALL 212 |
|
|
5136 |
0E37: BSF 0A.3 |
|
|
5137 |
0E38: MOVLW 20 |
|
|
5138 |
0E39: MOVWF 4A |
|
|
5139 |
0E3A: BCF 0A.3 |
|
|
5140 |
0E3B: CALL 212 |
|
|
5141 |
0E3C: BSF 0A.3 |
|
|
5142 |
0E3D: MOVLW 05 |
|
|
5143 |
0E3E: MOVWF 04 |
|
|
5144 |
0E3F: MOVF 3A,W |
|
|
5145 |
0E40: MOVWF 40 |
|
|
5146 |
0E41: MOVF 39,W |
|
|
5147 |
0E42: MOVWF 3F |
|
|
5148 |
0E43: MOVF 38,W |
|
|
5149 |
0E44: MOVWF 3E |
|
|
5150 |
0E45: MOVF 37,W |
|
|
5151 |
0E46: MOVWF 3D |
|
|
5152 |
0E47: CLRF 41 |
|
|
5153 |
0E48: CALL 2CB |
|
|
5154 |
0E49: MOVLW 50 |
|
|
5155 |
0E4A: MOVWF 4A |
|
|
5156 |
0E4B: BCF 0A.3 |
|
|
5157 |
0E4C: CALL 212 |
|
|
5158 |
0E4D: BSF 0A.3 |
|
|
5159 |
0E4E: MOVLW 61 |
|
|
5160 |
0E4F: MOVWF 4A |
|
|
5161 |
0E50: BCF 0A.3 |
|
|
5162 |
0E51: CALL 212 |
|
|
5163 |
0E52: BSF 0A.3 |
|
|
5164 |
0E53: MOVLW 20 |
|
|
5165 |
0E54: MOVWF 4A |
|
|
5166 |
0E55: BCF 0A.3 |
|
|
5167 |
0E56: CALL 212 |
|
|
5168 |
0E57: BSF 0A.3 |
|
|
5169 |
.................... |
|
|
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); |
|
|
5171 |
0E58: MOVLW 10 |
|
|
5172 |
0E59: MOVWF 04 |
|
|
5173 |
0E5A: MOVF 3C,W |
|
|
5174 |
0E5B: MOVWF 3E |
|
|
5175 |
0E5C: MOVF 3B,W |
|
|
5176 |
0E5D: MOVWF 3D |
|
|
5177 |
0E5E: CALL 39F |
|
|
5178 |
0E5F: MOVLW 20 |
|
|
5179 |
0E60: BTFSS 0C.4 |
|
|
5180 |
0E61: GOTO 660 |
|
|
5181 |
0E62: MOVWF 19 |
|
|
5182 |
0E63: MOVLW 89 |
|
|
5183 |
0E64: MOVWF 04 |
|
|
5184 |
0E65: MOVF 2A,W |
|
|
5185 |
0E66: MOVWF 40 |
|
|
5186 |
0E67: MOVF 29,W |
|
|
5187 |
0E68: MOVWF 3F |
|
|
5188 |
0E69: MOVF 28,W |
|
|
5189 |
0E6A: MOVWF 3E |
|
|
5190 |
0E6B: MOVF 27,W |
|
|
5191 |
0E6C: MOVWF 3D |
|
|
5192 |
0E6D: MOVLW 02 |
|
|
5193 |
0E6E: MOVWF 41 |
|
|
5194 |
0E6F: CALL 415 |
|
|
5195 |
0E70: MOVLW 20 |
|
|
5196 |
0E71: BTFSS 0C.4 |
|
|
5197 |
0E72: GOTO 671 |
|
|
5198 |
0E73: MOVWF 19 |
|
|
5199 |
0E74: MOVLW 89 |
|
|
5200 |
0E75: MOVWF 04 |
|
|
5201 |
0E76: MOVF 36,W |
|
|
5202 |
0E77: MOVWF 40 |
|
|
5203 |
0E78: MOVF 35,W |
|
|
5204 |
0E79: MOVWF 3F |
|
|
5205 |
0E7A: MOVF 34,W |
|
|
5206 |
0E7B: MOVWF 3E |
|
|
5207 |
0E7C: MOVF 33,W |
|
|
5208 |
0E7D: MOVWF 3D |
|
|
5209 |
0E7E: MOVLW 02 |
|
|
5210 |
0E7F: MOVWF 41 |
|
|
5211 |
0E80: CALL 415 |
|
|
5212 |
0E81: MOVLW 20 |
|
|
5213 |
0E82: BTFSS 0C.4 |
|
|
5214 |
0E83: GOTO 682 |
|
|
5215 |
0E84: MOVWF 19 |
|
|
5216 |
0E85: MOVLW 89 |
|
|
5217 |
0E86: MOVWF 04 |
|
|
5218 |
0E87: MOVF 2E,W |
|
|
5219 |
0E88: MOVWF 40 |
|
|
5220 |
0E89: MOVF 2D,W |
|
|
5221 |
0E8A: MOVWF 3F |
|
|
5222 |
0E8B: MOVF 2C,W |
|
|
5223 |
0E8C: MOVWF 3E |
|
|
5224 |
0E8D: MOVF 2B,W |
|
|
5225 |
0E8E: MOVWF 3D |
|
|
5226 |
0E8F: MOVLW 02 |
|
|
5227 |
0E90: MOVWF 41 |
|
|
5228 |
0E91: CALL 415 |
|
|
5229 |
0E92: MOVLW 20 |
|
|
5230 |
0E93: BTFSS 0C.4 |
|
|
5231 |
0E94: GOTO 693 |
|
|
5232 |
0E95: MOVWF 19 |
|
|
5233 |
0E96: MOVLW 05 |
|
|
5234 |
0E97: MOVWF 04 |
|
|
5235 |
0E98: MOVF 3A,W |
|
|
5236 |
0E99: MOVWF 40 |
|
|
5237 |
0E9A: MOVF 39,W |
|
|
5238 |
0E9B: MOVWF 3F |
|
|
5239 |
0E9C: MOVF 38,W |
|
|
5240 |
0E9D: MOVWF 3E |
|
|
5241 |
0E9E: MOVF 37,W |
|
|
5242 |
0E9F: MOVWF 3D |
|
|
5243 |
0EA0: MOVLW 02 |
|
|
5244 |
0EA1: MOVWF 41 |
|
|
5245 |
0EA2: CALL 415 |
|
|
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 |
3275 |
kaklik |
5308 |
.................... i++; |
3286 |
kaklik |
5309 |
0EE1: INCF 3B,F |
|
|
5310 |
0EE2: BTFSC 03.2 |
|
|
5311 |
0EE3: INCF 3C,F |
|
|
5312 |
.................... |
3275 |
kaklik |
5313 |
.................... Delay_ms(100); |
3286 |
kaklik |
5314 |
0EE4: MOVLW 64 |
|
|
5315 |
0EE5: MOVWF 4B |
|
|
5316 |
0EE6: BCF 0A.3 |
|
|
5317 |
0EE7: CALL 0FB |
|
|
5318 |
0EE8: BSF 0A.3 |
3275 |
kaklik |
5319 |
.................... } |
3286 |
kaklik |
5320 |
0EE9: GOTO 5B1 |
3275 |
kaklik |
5321 |
.................... |
|
|
5322 |
.................... } |
3286 |
kaklik |
5323 |
0EEA: SLEEP |
3275 |
kaklik |
5324 |
|
|
|
5325 |
Configuration Fuses: |
|
|
5326 |
Word 1: 2CF5 INTRC NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP NODEBUG |
|
|
5327 |
Word 2: 3FFF NOWRT BORV40 |