📄 main.c
字号:
/******************************************************************************/
/* This file is part of the kp weather station development */
/* Copyright kp 2005 */
/******************************************************************************/
/* */
/* Main.C: kp weather station main routine */
/* */
/******************************************************************************/
#include <stdio.h> // standard I/O .h-file
#include <LPC213x.H> // LPC213x definitions
#include <bsp.h> // include board support package
#include <math.h>
extern void init_registers(); // setup regiters to support MCB2180 and project
extern void init_serial (void); // Init Serial Interface function prototype
extern void init_clock (void); // Init clock Interface function prototype
extern void set_LED (unsigned char led_no, unsigned char led_cmd);
extern void init_timer();
extern void init_timer_1();
extern void delay(int delay_val);
extern int kp_printf(const char *fmt, ...);
extern void wr_byte(unsigned char d, unsigned char x); //d is the number of digits (leading zeros)
extern void wr_32hex(unsigned int x);
extern float wind_dir (void);
extern void wind_dir_char(void);
extern double wind_speed (unsigned int filterred_data);
extern void disp_lum(unsigned char x);
extern void disp_set_cursor(unsigned char r, unsigned char c);
extern void disp_clr(void);
extern float air_temp (unsigned char ad0);
extern float air_temp_F (float air_c);
extern int read_wind_dir_bits();
extern char wind_dir_str[3];
extern int volatile T0_flag;
extern unsigned volatile int timer_0_capture;
extern float wind_dir_ave;
extern unsigned int tval;
extern unsigned int val;
double speed;
unsigned char last_sec;
int main (void) {
float tmp1, tmp2, tmp3;
float ad0, ad1;
unsigned int n;
unsigned char task_active = 0x80; // lets try some tasking
// b x x | x x | x x | x x
// M | T1 | T2 | RTC 1st indicates "active"
init_registers();
init_serial(); // Initialize Serial Interface
init_timer(); // init timer 0
init_timer_1(); // init timer 1
init_clock(); // init real-time clock
printf("\n"); // clear displar
while (ON) { // while microprocess is on, Loop forever
if ( ((task_active)&(0x80)) == 0x80 ) { // test for active
set_LED(ZERO,ON); // indicate active
task_active &= 0x7F; // clear active bit (preserve all others)
}
else {
set_LED(ZERO,OFF); // indicate inactive
task_active |= 0x80; // set active bit
}
disp_lum(1); // display lighting (0=off, 1=20%...,5=100%
disp_set_cursor(0,0);
wind_dir_char();
speed=wind_speed(timer_0_capture);
printf(" Wind %s",wind_dir_str);
printf(" %2.1f MPH ",speed);
disp_set_cursor(1,0);
printf("Temp %3.0f",air_temp_F(air_temp(tval)));
putchar(0xDF); printf("F");
printf(" "); wr_byte(2,HOUR);
printf(":"); wr_byte(2,MIN);
printf(":"); wr_byte(2,SEC);
last_sec = SEC;
while (last_sec == SEC);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -