📄 sensor_routines.lst
字号:
ARM COMPILER V2.00d, sensor_routines 23/10/05 18:16:19 PAGE 1
ARM COMPILER V2.00d, COMPILATION OF MODULE sensor_routines
OBJECT MODULE PLACED IN .\Flash\sensor_routines.obj
COMPILER INVOKED BY: C:\KEIL\ARM\BIN\CA.EXE sensor_routines.c THUMB OPTIMIZE(7,SPEED) BROWSE DEBUG PRINT(.\FLASH\SENSOR_
-ROUTINES.LST) TABS(4) OBJECT(.\Flash\sensor_routines.obj)
stmt level source
1 /******************************************************************************/
2 /* This file is part of the kp development */
3 /* Copyright kp */
4 /******************************************************************************/
5 /* */
6 /* wind routines */
7 /* */
8 /******************************************************************************/
9
10 #include <LPC213x.H> // LPC21xx definitions
11 #include <bsp.h> // include board support package
12 #include <math.h>
13 #include <string.h>
14
15 float wind_dir_ave;
16 char wind_dir_str[3];
17
18 // read wind direction bits
19 int read_wind_dir_bits() {
20 1 int x;
21 1 x = IOPIN0;
22 1 x = x >> 20;
23 1 x = x & 0x00000007;
24 1 return(x);
25 1 }
26
27 // Read wind direction
28 float wind_dir (void) {
29 1 float azmith[8] = {225.0,270.0,315.0,0.0,45.0,90.0,135.0,180.0};
30 1 float tmp;
31 1 tmp = azmith[read_wind_dir_bits()];
32 1 // calculate wind direction in degrees 0-> North, 90-> E, etc.
33 1 // read io_address and strip out the three bits.
34 1 // Average reading and calulate angle
35 1 // wind_dir_ave = ((wind_dir_ave*4) + tmp)/5;
36 1 wind_dir_ave = tmp;
37 1 return(wind_dir_ave);
38 1 }
39
40 void wind_dir_char(void) {
41 1 unsigned char tmp;
42 1 tmp = read_wind_dir_bits();
43 1 switch (tmp) {
44 2 case 0: strcpy(wind_dir_str," E"); break;
45 2 case 1: strcpy(wind_dir_str,"SE"); break;
46 2 case 2: strcpy(wind_dir_str," S"); break;
47 2 case 3: strcpy(wind_dir_str,"SW"); break;
48 2 case 4: strcpy(wind_dir_str," W"); break;
49 2 case 5: strcpy(wind_dir_str,"NW"); break;
50 2 case 6: strcpy(wind_dir_str," N"); break;
51 2 case 7: strcpy(wind_dir_str,"NE"); break;
52 2 }
53 1
54 1 }
55 double wind_speed (unsigned int filterred_data) {
56 1 double speed, x, X;
57 1 // Get period from interrupt routine and calculate speed.
58 1 // Interrupt routine averages the data.
ARM COMPILER V2.00d, sensor_routines 23/10/05 18:16:19 PAGE 2
59 1 // Calculate wind_speed in MPH
60 1 // Anomometer calibration equation is
61 1 // f(X) = function of freqency // curve fit equation
62 1 // (24.342758-0.008535973*X+7.410868e-7*X^2), Where X=x^-1.0
63 1 double const A = -1.5562761;
64 1 double const B = 7.78138e7;
65 1 double const C = 1.0;
66 1 double const D = 2118805.0;
67 1 x=(double)filterred_data; // need to capture current value
68 1 // before interrupt routine modifies
69 1 X=pow(x,-1.0);
70 1 speed=(A+B*X)/(C+D*X);
71 1 if (speed < 0.0) speed = 0.0;
72 1 if (filterred_data > 50000000) speed = 0.0;
73 1 return(speed);
74 1 }
75
76 float air_temp (unsigned char ad0) {
77 1 float temp, v0;
78 1 // This routine will read the A/D for temperature.
79 1 // The readings are avaeraged.
80 1 // The retuned value if in degrees F
81 1 // general equation for AN22100
82 1 // Vout=(V/V5)*[1.375+(22.5mv/C)*Ta]
83 1 // rearanged assuming V/V5 = 1 (V is at 5 volts)
84 1 // Ta= (Vout-1.375)/(0.0225)
85 1 v0=((float)ad0/1023.0)*3.3; // convert to volts 3.3 reference
86 1 temp = (v0-1.375)/(0.0225);
87 1 return (temp);
88 1 }
89
90 float air_temp_F (float air_c) {
91 1 float air_f;
92 1 air_f = ((9.0/5.0)*air_c) +32.0;
93 1 return (air_f);
94 1 }
ARM COMPILER V2.00d, sensor_routines 23/10/05 18:16:19 PAGE 3
ASSEMBLY LISTING OF GENERATED OBJECT CODE
*** EXTERNALS:
EXTERN CODE16 (pow?T)
EXTERN CODE16 (strcpy?T)
EXTERN CODE16 (?C?FCASTU?T)
EXTERN CODE16 (?C?FPMUL?T)
EXTERN CODE16 (?C?FPADD?T)
EXTERN CODE16 (?C?FPDIV?T)
EXTERN CODE16 (?C?FPCMP?T)
EXTERN CODE16 (?C?FPSUB?T)
*** PUBLICS:
PUBLIC read_wind_dir_bits?T
PUBLIC wind_dir?T
PUBLIC wind_dir_char?T
PUBLIC wind_speed?T
PUBLIC air_temp?T
PUBLIC air_temp_F?T
PUBLIC wind_dir_ave
PUBLIC wind_dir_str
*** DATA SEGMENT '?CON?sensor_routines':
00000000 ?tpl?0001:
00000000 BEGIN_INIT
00000000 43610000 DF32 225
00000004 43870000 DF32 270
00000008 439D8000 DF32 315
0000000C 00000000 DF32 0
00000010 42340000 DF32 45
00000014 42B40000 DF32 90
00000018 43070000 DF32 135
0000001C 43340000 DF32 180
00000020 END_INIT
00000020 ??S_8:
00000020 DB 'NE',0x00
00000023 ??S_7:
00000023 DB ' N',0x00
00000026 ??S_6:
00000026 DB 'NW',0x00
00000029 ??S_5:
00000029 DB ' W',0x00
0000002C ??S_4:
0000002C DB 'SW',0x00
0000002F ??S_3:
0000002F DB ' S',0x00
00000032 ??S_2:
00000032 DB 'SE',0x00
00000035 ??S_1:
00000035 DB ' E',0x00
*** DATA SEGMENT '?DT0?sensor_routines':
00000000 wind_dir_ave:
00000000 DS 4
00000004 wind_dir_str:
00000004 DS 3
*** CODE SEGMENT '?PR?read_wind_dir_bits?T?sensor_routines':
19: int read_wind_dir_bits() {
00000000 ; SCOPE-START
21: x = IOPIN0;
00000000 4800 LDR R0,=0xE0028000
00000002 6800 LDR R0,[R0,#0x0]
00000004 ---- Variable 'x' assigned to Register 'R0' ----
22: x = x >> 20;
00000004 1500 ASR R0,R0,#0x14 ; x
ARM COMPILER V2.00d, sensor_routines 23/10/05 18:16:19 PAGE 4
23: x = x & 0x00000007;
00000006 2107 MOV R1,#0x7
00000008 4008 AND R0,R1
24: return(x);
0000000A ; SCOPE-END
25: }
0000000A 4770 BX R14
0000000C ENDP ; 'read_wind_dir_bits?T'
*** CODE SEGMENT '?PR?wind_dir?T?sensor_routines':
28: float wind_dir (void) {
00000000 B500 PUSH {LR}
00000002 B088 SUB R13,#0x20
00000004 ; SCOPE-START
29: float azmith[8] = {225.0,270.0,315.0,0.0,45.0,90.0,135.0,180.0};
00000004 4800 LDR R1,=?tpl?0001 ; ?tpl?0001
00000006 A800 ADD R0,R13,#0x0
00000008 2220 MOV R2,#0x20
0000000A L_18:
0000000A 780B LDRB R3,[R1,#0x0]
0000000C 7003 STRB R3,[R0,#0x0]
0000000E 1C49 ADD R1,R1,#0x1
00000010 1C40 ADD R0,R0,#0x1
00000012 1E52 SUB R2,R2,#0x1
00000014 D1F9 BNE L_18 ; T=0x0000000A
31: tmp = azmith[read_wind_dir_bits()];
00000016 F7FF BL read_wind_dir_bits?T ; T=0x0001 (1)
00000018 FFF3 BL read_wind_dir_bits?T ; T=0x0001 (2)
0000001C 0081 LSL R1,R0,#0x2 ; read_wind_dir_bits?T
0000001E A800 ADD R0,R13,#0x0
00000020 5841 LDR R1,[R0,R1]
00000022 ---- Variable 'tmp' assigned to Register 'R1' ----
36: wind_dir_ave = tmp;
00000022 4800 LDR R0,=wind_dir_ave ; wind_dir_ave
00000024 6001 STR R1,[R0,#0x0] ; tmp
37: return(wind_dir_ave);
00000026 4800 LDR R0,=wind_dir_ave ; wind_dir_ave
00000028 6800 LDR R0,[R0,#0x0] ; wind_dir_ave
0000002A ; SCOPE-END
38: }
0000002A B008 ADD R13,#0x20
0000002C BC08 POP {R3}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -