BMP180气压传感器调试

</pre><p>BMP180气压传感器具有体积小,功耗低等优点,因为广泛的被应用于手机,手表等小型编写式设计,在淘宝上看到有现成的模块,就买了一个玩玩,目的是想将它和CC2540组合,做一个电子气压计,并通过蓝牙传送到手机。下面为BMP180在CC2540上的测试程序。</p><p></p><p></p><pre name="code" class="cpp"><span style="font-family: Arial, Helvetica, sans-serif;">#include<ioCC2540.h></span>
#include "bmp180.h"
//#include "bmpi2c.h"
 
#include  <math.h>    //Keil library 
#include  <stdlib.h>  //Keil library 
#include  <stdio.h>   //Keil library
 
#define   uchar unsigned char
#define   uint unsigned int
 
 
#define BMP085_SlaveAddress   0xee  //定义器件在IIC总线中的从地址                              
#define OSS 0// Oversampling Setting (note: code is not set up to use other OSS values)
 
 
typedef unsigned char  BYTE;
typedef unsigned short WORD;
 
long  temperature = 8;//温度值
long  pressure = 8;//压力值
long  height = 8;//相对海拔高度值
 
//uchar ge,shi,bai,qian,wan,shiwan;           //显示变量
int  dis_data;                              //变量
 
short ac1;
short ac2;
short ac3;
unsigned short ac4;
unsigned short ac5;
unsigned short ac6;
short b1;
short b2;
short mb;
short mc;
short md;

void Delay5us()
{
  unsigned int i,j;
  for(i=0;i<5;i++)
    for(j=0;j<50;j++);
  return;
}

void Delay_1ms(unsigned char msDelay)
{
  unsigned int i,j;
  for(i=0;i<msDelay;i++)
    for(j=0;j<5;j++);
  return;
}
/**************************************
延时5毫秒(STC90C52RC@12M)
不同的工作环境,需要调整此函数
当改用1T的MCU时,请调整此延时函数
**************************************/
void Delay5ms()
{
 
    WORD n = 25;
 
    while (n--);
 
}
 
 
/**************************************
起始信号
**************************************/
void BMP085_Start()
{
    P1DIR |= 0X01;
    SDA=1;                    //拉高数据线
    SCL=1;                    //拉高时钟线
    Delay5us();                 //延时
    SDA=0;                    //产生下降沿
    Delay5us();                 //延时
    SCL = 0;                    
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值