• 大小: 63KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-10
  • 语言: 其他
  • 标签: BH1750  CC2530  

资源简介

CC2530读取光照传感器BH1750数据,已通过验证,可以正常使用

资源截图

代码片段和文件信息

/************************************************
connect all the event to the interrupt1
**************************************************/
#include “Detect.h“
#include “MMA845X.h“
#include “IIC.h“
#include “Timer.h“
#include “ioCC2530.h“


unsigned char IntSourceMotion;
unsigned char IntSourceFF;
unsigned char IntSourceTrans;
unsigned char State;
//unsigned char Data[6];


void TransientDetectInit(unsigned char SlaveAddress)
{
 RegWrite(SlaveAddress0x2A 0x18);    //Set device in 100 Hz ODR Standby
 RegWrite(SlaveAddress0x1D 0x16);    //Enable Latch Enable X and Enable Y 
 RegWrite(SlaveAddress0x1F 0x20);    //set the threshold 2g 判断是否发生了撞击
 RegWrite(SlaveAddress0x20 0x05);    //ODR=100HZ 10ms per step size. set the debounce counter for 50 ms
 RegWrite(SlaveAddress0x2D 0x20);    //enable transition detection interrupt in the system control register.
// RegWrite(SlaveAddress0x2E 0x20);    //route the transient int to INT1 hardware pin
 RegWrite(SlaveAddress0x2E 0x00);    //route the transient int to INT2 hardware pin
 RegWrite(SlaveAddress0x2A(RegRead(SlaveAddress0x2A)|0x01));  //put the device into active mode
}


void MotionDetectInit(unsigned char SlaveAddress)
{
  RegWrite(SlaveAddress0x2A 0x18);   //Set the device in 100 Hz ODR Standby
  RegWrite(SlaveAddress0x15 0xD8);   //set the configuration for motion detection by setting the “OR“ condition OAE=1enableing XY and the latch
  RegWrite(SlaveAddress0x17 0x30);   //threshold setting value for the motion detection of>3g
  RegWrite(SlaveAddress0x18 0x0A);   //now step time is 10ms.set the debounce counter to eliminate false reading for 100HZ sample rate with a requirement of 100ms timer
  RegWrite(SlaveAddress0x2D 0x04);   //Enbale motion/freefall interrupt function in the system
  RegWrite(SlaveAddress0x2E 0x04);   //route the MF interrupt function to int1 pin
  RegWrite(SlaveAddress0x2ARegRead(SlaveAddress0x2A)|0x01);  //put the device in active mode
}


void FreefallDetectInit(unsigned char SlaveAddress)
{
RegWrite(SlaveAddress0x2A 0x20);  //Set the device in 50 Hz ODR Standby
RegWrite(SlaveAddress0x15 0xB8); //configuration register set for freefall detection enabling “AND“ conditionOAE=0enabling xyz and the latch
RegWrite(SlaveAddress0x17 0x0C); //threhold setting value for resulting acceleration<0.75g
RegWrite(SlaveAddress0x18 0x02); //set the debounce to eliminate false positive reading for 50HZ sample rate with reqirement of 40ms timerassuming normal mode
RegWrite(SlaveAddress0x2D 0x04);  //enable MF interrupt function in the system
RegWrite(SlaveAddress0x2E 0x04); //route the MF interrupt function int1 harware pin
RegWrite(SlaveAddress0x2ARegRead(SlaveAddress0x2A)|0x01);
}

void FallEventInit(unsigned char SlaveAddress)
{
  RegWrite(SlaveAddress0x2A 0x18);        //设置采样率
  RegWrite(SlaveAddress0x15 0xB8);        //设置自由落体测量模式,并使能在X,Y,Z三个方向上面测量
  RegWrite(SlaveAddres

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-03-15 21:29  BH1750程序forCC2530\
     目录           0  2012-09-20 14:38  BH1750程序forCC2530\Debug\
     目录           0  2014-03-15 21:29  BH1750程序forCC2530\Debug\Exe\
     文件       26069  2012-09-10 16:37  BH1750程序forCC2530\Debug\Exe\IIC.hex
     目录           0  2014-04-15 22:56  BH1750程序forCC2530\Debug\List\
     目录           0  2014-03-15 21:29  BH1750程序forCC2530\Debug\Obj\
     文件       38127  2012-09-10 16:37  BH1750程序forCC2530\Debug\Obj\Detect.r51
     文件         707  2011-04-19 14:19  BH1750程序forCC2530\Debug\Obj\FMDetect.pbi
     文件         539  2012-09-10 16:37  BH1750程序forCC2530\Debug\Obj\IIC.pbd
     文件       31161  2012-09-10 16:37  BH1750程序forCC2530\Debug\Obj\IIC.r51
     文件        4941  2012-09-10 16:37  BH1750程序forCC2530\Debug\Obj\MMA845X.r51
     文件        1245  2011-04-09 20:23  BH1750程序forCC2530\Debug\Obj\Terminal.r51
     文件        5005  2012-09-10 16:37  BH1750程序forCC2530\Debug\Obj\Timer.r51
     文件        5403  2012-09-10 16:37  BH1750程序forCC2530\Debug\Obj\Uart.r51
     文件       20169  2012-09-10 16:37  BH1750程序forCC2530\Debug\Obj\main.r51
     文件        8990  2012-09-10 17:28  BH1750程序forCC2530\IIC.dep
     文件       26857  2011-04-07 10:48  BH1750程序forCC2530\IIC.ewd
     文件       53926  2011-05-01 11:58  BH1750程序forCC2530\IIC.ewp
     文件         157  2011-04-07 10:48  BH1750程序forCC2530\IICforCC2530.eww
     目录           0  2014-03-15 21:29  BH1750程序forCC2530\settings\
     文件        2494  2012-09-10 17:28  BH1750程序forCC2530\settings\IIC.cspy.bat
     文件        6243  2012-09-10 17:28  BH1750程序forCC2530\settings\IIC.dbgdt
     文件         735  2012-09-10 17:28  BH1750程序forCC2530\settings\IIC.dni
     文件        3986  2012-09-10 17:28  BH1750程序forCC2530\settings\IICforCC2530.wsdt
     目录           0  2014-03-15 21:29  BH1750程序forCC2530\source\
     文件       11497  2011-05-01 12:06  BH1750程序forCC2530\source\Detect.c
     文件        1249  2011-04-30 21:15  BH1750程序forCC2530\source\Detect.h
     文件        5820  2011-05-01 17:56  BH1750程序forCC2530\source\IIC.c
     文件        1255  2011-05-01 17:56  BH1750程序forCC2530\source\IIC.h
     文件         892  2011-04-12 10:42  BH1750程序forCC2530\source\MMA845X.c
     文件       19534  2012-08-13 21:59  BH1750程序forCC2530\source\MMA845X.h
............此处省略5个文件信息

评论

共有 条评论