/******************************************************************************
*
龙丘MMA7455三轴加速度模块
CodeWarror:6.2
编写:龙丘
Designed by Chiu Sir
E-mail:[email protected]
软件版本:V1.0
最后更新:2010年10月12日
相关信息参考下列地址:
网站: http://www.lqist.cn
淘宝店:http://shop36265907.taobao.com
*
***************************************************************************//*!
*
* @file main.c
*
* @author longqiu
*
* @version 2.0.0.1
*
* @date Oct-12-2010
*
* @brief ION (MMA7455L) - Ion MMA7455L in Measure mode (using SPI or IIC)
*
*******************************************************************************
*
*
*
******************************************************************************/
#include "derivative.h" /* include peripheral declarations */
#include "doonstack.h"
#include "main.h"
#include "my_types.h"
#include "mcu_init.h"
#include "sw_spi.h"
#include "sw_iic.h"
#include "sci.h"
#pragma DATA_SEG SHORT _DATA_ZEROPAGE
byte n;
byte X,Y,Z; //Ion MMA7455L acceleration data (8Bits)
byte ion_reg[32]; //Array to read content of Ion MMA7455L registers
signed int calib[3];
byte mode = ION_MEASURE;
byte iic_active = 1; //IIC (select "1") or SPI (select "0")
void (*p_Ion_InitInterface)(void) = SwIIC_Init;
byte (*p_Ion_ReadByte)(byte) = SwIIC_ReadByte;
void (*p_Ion_WriteByte)(byte, byte) = SwIIC_WriteByte;
void (*p_Ion_MultiReadBytes)(byte, byte*, byte) = SwIIC_MultiReadBytes;
#pragma DATA_SEG DEFAULT
READ_REGXOUTL ReadRegXOUTL; //Review XOUTL in Real-Time Debugger
READ_REGXOUTH ReadRegXOUTH; //Review XOUTH in Real-Time Debugger
READ_REGYOUTL ReadRegYOUTL; //Review YOUTL in Real-Time Debugger
READ_REGYOUTH ReadRegYOUTH; //Review YOUTH in Real-Time Debugger
READ_REGZOUTL ReadRegZOUTL; //Review ZOUTL in Real-Time Debugger
READ_REGZOUTH ReadRegZOUTH; //Review ZOUTH in Real-Time Debugger
READ_REGXOUT8 ReadRegXOUT8; //Review XOUT8 in Real-Time Debugger
READ_REGYOUT8 ReadRegYOUT8; //Review YOUT8 in Real-Time Debugger
READ_REGZOUT8 ReadRegZOUT8; //Review ZOUT8 in Real-Time Debugger
READ_REGSTATUS ReadRegSTATUS; //Review STATUS in Real-Time Debugger
READ_REGDETSR ReadRegDETSRC; //Review DETSRC in Real-Time Debugger
READ_REGTOUT ReadRegTOUT; //Review TOUT in Real-Time Debugger
READ_REGRESERVED1 ReadRegRESERVED1; //Review RESERVED1 in Real-Time Debugger
READ_REGI2CAD ReadRegI2CAD; //Review I2CAD in Real-Time Debugger
READ_REGUSRINF ReadRegUSRINF; //Review USRINF in Real-Time Debugger
READ_REGWHOAMI ReadRegWHOAMI; //Review WHOAMI in Real-Time Debugger
READ_REGXOFFL ReadRegXOFFL; //Review XOFFL in Real-Time Debugger
READ_REGXOFFH ReadRegXOFFH; //Review XOFFH in Real-Time Debugger
READ_REGYOFFL ReadRegYOFFL; //Review YOFFL in Real-Time Debugger
READ_REGYOFFH ReadRegYOFFH; //Review YOFFH in Real-Time Debugger
READ_REGZOFFL ReadRegZOFFL; //Review ZOFFL in Real-Time Debugger
READ_REGZOFFH ReadRegZOFFH; //Review ZOFFH in Real-Time Debugger
READ_REGINTRST ReadRegINTRST; //Review INTRST in Real-Time Debugger
READ_REGMCTL ReadRegMCTL; //Review MCTL in Real-Time Debugger
READ_REGCTL1 ReadRegCTL1; //Review CTL1 in Real-Time Debugger
READ_REGCTL2 ReadRegCTL2; //Review CTL2 in Real-Time Debugger
READ_REGLDTH ReadRegLDTH; //Review LDTH in Real-Time Debugger
READ_REGPDTH ReadRegPDTH; //Review PDTH in Real-Time Debugger
READ_REGPW ReadRegPW; //Review PW in Real-Time Debugger
READ_REGLT ReadRegLT; //Review LT in Real-Time Debugger
READ_REGTW ReadRegTW; //Review TW in Real-Time Debugger
READ_REGRESERVED2 ReadRegRESERVED2; //Review RESERVED2 in Real-Time Debugger
#pragma CONST_SEG EEPROM
const signed int calib_eeprom[3];
/**************************************************************
* Function: Dummy_Pointer
* Parameters: dummy pointer to void
* Return: None
*
* Note: Dummy function
* (SPI does not allow multiple write/read)
**************************************************************/
#pragma MESSAGE DISABLE C5703 /*
* Warning C5703: Not used declared parameter
*/
void Dummy_Pointer(byte dum1, void *dummy, byte dum2)
{
}
/**************************************************************
* Function: CheckButt0
* Parameters: None
* Return: None
*
* Note: Specific routine execution if button pressed
**************************************************************/
void CheckButt0(void)
{
static byte last_st = 0;
if(BUTTON0 != last_st)
{
if(BUTTON0 == 0)
{
LED1_OFF;
Delay_Xms(200);
LED1_ON;
Set_SelfTest(); //Specific routine
}
}
last_st = BUTTON0;
}
/**************************************************************
* Function: CheckButt1
* Parameters: None
* Return: None
*
* Note: Specific routine execution if button pressed
**************************************************************/
void CheckButt1(void)
{
static byte last_st = 0;
if(BUTTON1 != last_st)
{
if(BUTTON1 == 0)
{
LED2_OFF;
Delay_Xms(200);
LED2_ON;
Clear_SelfTest();
ReadAllIonRegisters(); //Specific routine
}
}
last_st = BUTTON1;
}
/**************************************************************
* Function: CheckButt2
* Parameters: None
* Return: None
*
* Note: Specific routine execution if button pressed
**************************************************************/
void CheckButt2(void)
{
static byte last_st = 0;
if(BUTTON2 != last_st)
{
if(BUTTON2 == 0)
{
LED3_OFF;
Delay_Xms(200);
LED3_ON;
SetUp_ModeOfSensorIon(ION_G8); //Specific routine
}
}
last_st = BUTTON2;
}
/**************************************************************
* Function: CheckButt3
* Parameters: None
* Return: None
*
* Note: Specific routine execution if button pressed
**************************************************************/
void CheckButt3(void)
{
static byte last_st = 0;
if(BUTTON3 != last_st)
{
if(BUTTON3 == 0)
{
LED4_OFF;
Delay_Xms(200);
LED4_ON;
SetUp_ModeOfSensorIon(ION_G2); //Specific routine
}
}
last_st = BUTTON3;
}
/**************************************************************
* Function: main
* Parameters: None
* Return: None
*
* Note: Interface with Ion (MMA7455L) using SPI or IIC
* and transfer data in SCI
**************************************************************/
void main(void)
{
//MCU init
MCU_Init();
//SCI init
SCI_Init();
INIT_LED_MACRO
INIT_BUTTONS_MACRO
Delay_Xms(50);
LED1_ON;
//ION init
ION_DVDD_INIT;
ION_AVDD_INIT;
ION_DVDD_ON;
ION_AVDD_ON;
Delay_Xms(50);
LED2_ON;
// Select IIC or SPI communication
Change_SensorInterface();
// Init Ion (measure mode 2g range selected)
Init_SensorIon();
Delay_Xms(50);
LED3_ON;
// Initialization flash memory (store calibration data)
FCDIV = FCDIV_PRDIV8_MASK | (10 & FCDIV_DIV_MASK);
// Load previous calibration data (Ion MMA7455L does not keep calibration data)
for(n=0;n<3;n++)
{
p_Ion_WriteByte(XOFFL + n*2,
没有合适的资源?快使用搜索试试~ 我知道了~
龙丘科技mma7455资料
共46个文件
cmd:13个
h:8个
c:6个
需积分: 10 60 下载量 74 浏览量
2011-03-15
10:14:49
上传
评论 1
收藏 111KB RAR 举报
温馨提示
mma7455相关程序,简介,。。。。。。。。。。。。。。。。。。。。。
资源推荐
资源详情
资源评论
收起资源包目录
MMA7445forGB60.rar (46个子文件)
MMA7445
BDM_P&E_Multilink_CyclonePro.ini 2KB
bin
Project.abs 136KB
doonstack.dbg 10KB
Project.old0.map 77KB
Project.old2.map 82KB
Project.map 82KB
Project.abs.s19 7KB
Project.old1.map 84KB
Sources
mcu_init.h 2KB
main.h 9KB
sw_spi.c 3KB
main.c 33KB
my_types.h 19KB
sw_iic.h 3KB
sw_spi.h 4KB
sci.c 2KB
mcu_init.c 4KB
Start08.c 10KB
derivative.h 423B
sw_iic.c 13KB
sci.h 2KB
default.pe 168B
C_Layout.hwl 856B
Default.mem 161B
prm
Project.prm 2KB
burner.bbl 140B
ProjectOld.prm 2KB
MMA7445GB60.mcp 108KB
HCS08_OpenSourceBDM.ini 982B
DoOnStack
doonstack.asm 6KB
doonstack.inc 4KB
doonstack.h 1KB
HCS08_Full_Chip_Simulator.ini 2KB
cmd
HCS08_OpenSourceBDM_Preload.cmd 60B
HCS08_OpenSourceBDM_Erase_Unsecure.cmd 3KB
HCS08_OpenSourceBDM_Reset.cmd 60B
HCS08_Full_Chip_Simulator_Reset.cmd 60B
BDM_P&E_Multilink_CyclonePro_Startup.cmd 59B
HCS08_Full_Chip_Simulator_Startup.cmd 59B
HCS08_OpenSourceBDM_Startup.cmd 59B
BDM_P&E_Multilink_CyclonePro_Reset.cmd 60B
BDM_P&E_Multilink_CyclonePro_Preload.cmd 60B
HCS08_Full_Chip_Simulator_Preload.cmd 60B
HCS08_OpenSourceBDM_Postload.cmd 59B
BDM_P&E_Multilink_CyclonePro_Postload.cmd 59B
HCS08_Full_Chip_Simulator_Postload.cmd 59B
共 46 条
- 1
资源评论
zhanglina024042
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功