/*********************************************************************************
*** ***
*** Examples3 : MMA7455L PULSE DETECTION MODE(FreeFall-Detection) ***
*** 3Axis Accelerometer For "CP-JRARM7LPC2138 ***
*** : Interface I2C :ID 0x1D (Use I/O PIN) ***
*** ***
*********************************************************************************
*** ***
*** Target MCU : LPC2138 ***
*** : X-TAL : 19.6608 MHz ***
*** : PLL Setup = M(3),P(2) ***
*** : Run Speed 58.9824 MHz(With PLL)(19.6608MHz x 3 = 58.9824 MHz***
*** : VPB Clock(pclk) = CPU Clock/2 = 58.9824MHz/2 = 29.4912 MHz ***
*** : CPU Clock(cclk) = 58.9824 MHz ***
*** ***
*** Editor : uVision3 (V3.60) ***
*** Compiler : RealView MDK-ARM 3.20 ***
*** ***
*** Create By : Mr. Sittiphol Yooyod (WWW.ETT.CO.TH) ***
*** Last Update : 30/August/2010 ***
*** ***
*** ***
*** Port Interface : <LPC2138 PIN> <MMA7455L PIN> ***
*** ***
*** I2C : ***
*** P0.17 : SCK(out) Connect CLK ***
*** P0.18 : SDA(In/Out) Connect SDA ***
*** P0.21 : (Status-In) Connect INT1/DRDY ***
*** ***
*** <LED/Buzzer> ***
*** ***
*** Display : -P0.22 :(Output) Connect LED(1=ON) ***
*** -P0.23 :(Output) Connect Buzzer(1=ON) ***
*** ***
*** Operate : When Pulse detected(by give Sensor Fall down )PHO=Toggle ***
*** and have sound beep ***
*** ***
*********************************************************************************/
#include "LPC213x.h"
#include "stdio.h"
//**************** Define Register Command **********************
#define XOUTL 0x00 //00 10 bits output value X LSB (Read only)
#define XOUTH 0x01 //01 10 bits output value X MSB (Read only)
#define YOUTL 0x02 //02 10 bits output value Y LSB (Read only)
#define YOUTH 0x03 //03 10 bits output value Y MSB (Read only)
#define ZOUTL 0x04 //04 10 bits output value Z LSB (Read only)
#define ZOUTH 0x05 //05 10 bits output value Z MSB (Read only)
#define XOUT8 0x06 //06 8 bits Output value X (Read only)
#define YOUT8 0x07 //07 8 bits Output value Y (Read only)
#define ZOUT8 0x08 //08 8 bits Output value Z (Read only)
#define STATUS 0x09 //09 Status registers (Read only)
#define DETSRC 0x0A //10 Detection source registers (Read only)
#define I2CAD 0x0D //13 I2C device address (Bit[6:0]: Read only, Bit[7]: Read/Write)
#define USRINF 0x0E //14 User information (Optional, Read only)
#define WHOAMI 0x0F //15 Who am I value (Optional, Read only)
#define XOFFL 0x10 //16 Offset drift X value (LSB) (Read/Write)
#define XOFFH 0x11 //17 Offset drift X value (MSB) (Read/Write)
#define YOFFL 0x12 //18 Offset drift Y value (LSB) (Read/Write)
#define YOFFH 0x13 //19 Offset drift Y value (MSB) (Read/Write)
#define ZOFFL 0x14 //20 Offset drift Z value (LSB) (Read/Write)
#define ZOFFH 0x15 //21 Offset drift Z value (MSB) (Read/Write)
#define MCTL 0x16 //22 Mode control (Read/Write)
#define INTRST 0x17 //23 Interrupt latch reset (Read/Write)
#define CTL1 0x18 //24 Control 1 (Read/Write)
#define CTL2 0x19 //25 Control 2 (Read/Write)
#define LDTH 0x1A //26 Level detection threshold limit value (Read/Write)
#define PDTH 0x1B //27 Pulse detection threshold limit value (Read/Write)
#define PD 0x1C //28 Pulse duration value (Read
#define LT 0x1D //29 Latency time value (Read/Write)
#define TW 0x1E //30 Time window for second pulse value(Read/Write)
//----------------- Define I2C Pin ------------------
#define SCK_HI() IOSET0 = 0x00020000 //P0.17=SCK:1
#define SCK_LO() IOCLR0 = 0x00020000 //P0.17=SCK:0
#define SDA_HI() IOSET0 = 0x00040000 //P0.18=SDA:1
#define SDA_LO() IOCLR0 = 0x00040000 //P0.18=SDA:0
#define SDA_IN() IODIR0 &= 0xFFFBFFFF //P0.18=Input
#define SDA_OUT() IODIR0 |= 0x00040000 //P0.18=Output
#define SDA IOPIN0 //Referent SDA = IOPIN0 for P0.18(input)
#define INT1 IOPIN0 //Referent INT1 = IOPIN0 for P0.21(Input)
#define LED_ON() IOSET0 = 0x00400000 //P0.22:LED =1=ON
#define LED_OFF() IOCLR0 = 0x00400000 // =0=OFF
#define Buz_On() IOSET0 = 0x00800000 //P0.23:Buzzer=1=ON
#define Buz_Off() IOCLR0 = 0x00800000 // =0=OFF
/**********************************************************
** Function Delay **
**********************************************************/
void delay(int cnt)
{
int i,j ;
for(i=0;i<cnt;i++)
for(j=0;j<cnt;j++) ;
}
/***********************************************************
** Initial Port **
***********************************************************/
void init_port(void)
{
//------ Set GPIO PIN -------
PINSEL0 = 0x00000000 ; //Set Port0-PIN[0..15] = GPIO
PINSEL1 = 0x00000000 ; //Set Port0-PIN[16..31]= GPIO
//------ Set Direction of GPIO PIN -------
IODIR0 = 0xFFDFFFFF ; //Set Port0-PIN[21] = Input,Port0-PIN[Other]=Output
//--------- Default Value Port0 ---------
IOPIN0 = 0x00000000 ; //Set Data Port0 = 0
//--------- Initial Uart0 ----------
U0LCR = 0x83 ; //8 bits, no Parity, 1 Stop bit
U0DLL = 192 ; //9600 Baud Rate @ 29.491 MHz VPB Clock
U0LCR = 0x03 ; //DLAB = 0
}
/*******************************************************************
没有合适的资源?快使用搜索试试~ 我知道了~
Pulse_Detection_Mode.rar_pulse detection
共20个文件
o:2个
bak:2个
sct:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 76 浏览量
2022-09-21
08:48:24
上传
评论
收藏 48KB RAR 举报
温馨提示
Accelelrometer Pulse Detection mode by spi 4 wire with arm7
资源推荐
资源详情
资源评论
收起资源包目录
Pulse_Detection_Mode.rar (20个子文件)
Pulse_Detection_Mode
PULSE_DETEC_MODE.Uv2 3KB
PULSE_DETEC_MODE_Opt.Bak 1017B
PULSE_DETEC_MODE.axf 13KB
PULSE_DETEC_MODE.lnp 291B
PULSE_DETEC_MODE.plg 297B
Startup.o 3KB
PULSE_DETEC_MODE.Opt 1015B
PULSE_DETEC_MODE.map 29KB
PULSE_DETEC_MODE_Target 1.dep 517B
pulse_detec_mode.o 27KB
PULSE_DETEC_MODE.tra 993B
PULSE_DETEC_MODE_Uv2.Bak 0B
PULSE_DETEC_MODE.sct 479B
PULSE_DETEC_MODE.htm 24KB
Pulse_detec_mode.c 18KB
Startup.lst 45KB
PULSE_DETEC_MODE.hex 7KB
pulse_detec_mode.crf 14KB
Startup.s 15KB
pulse_detec_mode.d 145B
共 20 条
- 1
资源评论
御道御小黑
- 粉丝: 61
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功