📄 freescale
字号:
/** ###################################################################
** Filename : accelerometer.C
** Project : accelerometer
** Processor : MC9S08JM60CLHE
** Version : Driver 01.11
** Compiler : CodeWarrior HCS08 C Compiler
** Date/Time : 2009-10-12, 17:37
** Abstract :
** Main module.
** This module contains user's application code.
** Settings :
** Contents :
** No public methods
**
** (c) Copyright UNIS, spol. s r.o. 1997-2008
** UNIS, spol. s r.o.
** Jundrovska 33
** 624 00 Brno
** Czech Republic
** http : www.processorexpert.com
** mail : info@processorexpert.com
** ###################################################################*/
/* MODULE accelerometer */
/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "Events.h"
#include "AD1.h"
#include "ST.h"
#include "LCD_DATA.h"
#include "LCD_CONTROL.h"
/* Include shared modules, which are used for whole project */
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"
#include "LCD1602.h"
#include "MMA1220_60D.h"
/* GLOBAL VARIABLES DEFINITION */
Uchar near gu8TopAccValue = 0;
Uchar near gau8LcdFirstLine[] = "MMA1220: . G ";
Uchar near gu8AccSelect;
Uchar near gu8Wait5msCount;
bool near gbResetTop = TRUE;
bool near gbOveraccState = FALSE;
void InitHardware(void)
{
/* Initial set-up of LCD */
Lcd_Init();
/* Self-Test pin toggle to reset Status latch on the Accelerometers */
ST_ClrVal();;
WaitNms(50);
ST_SetVal();
WaitNms(50);
ST_ClrVal();
return;
}
void main(void)
{
/* Write your local variable definition here */
Uchar au8Lcd2ndLine[]="MAX: . G --- ";
Uchar u8NewAdcValue;
bool bNewTopValue;
/* Read data from MMA1220 initially */
gu8AccSelect = MMA1220;
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
PE_low_level_init();
/*** End of Processor Expert internal initialization. ***/
InitHardware();
/* Display Welcome message on LCD */
Lcd_Disp_Str(0x00, 0x02, "ACCELEROMETER");
Lcd_Disp_Str(0x01, 0x00, "EVALUATION BOARD");
/* Wait for 0.75 seconds */
WaitNms(250);
WaitNms(250);
WaitNms(250);
/* Hardware test on the Accelerometers */
AccTest(MMA1220);
WaitNms(250);
AccTest(MMA1260);
WaitNms(250);
for(;;)
{
/* Get new value from the Accelerometer selected. The data is
formatted to Gs. The flag bNewTopValue indicates if there is a
new top value. */
// u8NewAdcValue = AD1_GetValue16(gu8AccSelect);
bNewTopValue = AccDataFormat(u8NewAdcValue);
/* LCD first line is constantly refreshed with the newest ADC value */
Lcd_Disp_Str(0x00, 0x05, gau8LcdFirstLine);
/* Check if there is a new top value. */
if(bNewTopValue){
/* Copy the data already formatted from the first LCD line to the
second line. */
au8Lcd2ndLine[5] = gau8LcdFirstLine[9];
au8Lcd2ndLine[6] = gau8LcdFirstLine[10];
au8Lcd2ndLine[8] = gau8LcdFirstLine[12];
/* Display "!!!" warning in case the new reading is outside
spec range. */
if(gbOveraccState){
au8Lcd2ndLine[12] = '!';
au8Lcd2ndLine[13] = '!';
au8Lcd2ndLine[14] = '!';
}
else{
au8Lcd2ndLine[12] = '-';
au8Lcd2ndLine[13] = '-';
au8Lcd2ndLine[14] = '-';
}
/* Refresh LCD second line with new value */
Lcd_Disp_Str(0x01, 0x05, au8Lcd2ndLine);
}
}
/* Write your code here */
/* For example: for(;;) { } */
/*** Don't write any code pass this line, or it will be deleted during code generation. ***/
/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
for(;;){}
/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
/* END accelerometer */
/*
** ###################################################################
**
** This file was created by UNIS Processor Expert 3.03 [04.07]
** for the Freescale HCS08 series of microcontrollers.
**
** ###################################################################
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -