-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.c
More file actions
67 lines (56 loc) · 1.34 KB
/
App.c
File metadata and controls
67 lines (56 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "system.h"
uint8_t testbuff[64];
void APP_Init() {
#ifdef DebugFlag //DebugFlag is defined in App.h
Timer0_Start(200); //ms unit, 16bits
#else
Timer0_Start(8); //ms unit, 16bits
#endif
}
void DebugMsg() {
MMA7660GetDate();
HAL_Read_Button();
sprintf(testbuff, "Chansu DEBUG: B:%X,GX:%d,GY:%d,XYZ[%d:%d:%d]\n", Button, HAL_Read_ADC(GyroX_ADC_Port), HAL_Read_ADC(GyroY_ADC_Port), \
(short)AccX, (short)AccY, (short)AccZ);
UartTX(testbuff, mystrlen(testbuff));
}
void Operations() {
HAL_Read_Button();
if(Button==0) {
UartStop();
LEDOff();
B_L_Click_Null();
B_R_Click_Null();
B_Conn_Null();
} else if (Button==RightClickB) {
B_R_Click_On();
} else if (Button==LeftClickB) {
B_L_Click_On();
} else if (Button==AdditionB) {
LEDOn();
B_Conn_On();
}
// 자이로 값과 가속도 값 측정
MMA7660GetDate();
HPL_Get_GyroData();
// 12bit크기의 X/Y 데이터로 변환
{
uint8_t *array;
HPL_ISR_GLOBAL_CLR();
array = (uint8_t *)&Xvalue;
SPI_DATA_XL = array[0];
SPI_DATA_XYH = array[1]<<4;
array = (uint8_t *)&Yvalue;
SPI_DATA_YL = array[0];
SPI_DATA_XYH |= array[1]&0x0F;
HPL_ISR_GLOBAL_SET();
}
B_ADNS_Motion_On();
}
void Timer0_Expire_Task() {
#ifdef DebugFlag //DebugFlag is defined in App.h
DebugMsg();
#else
Operations();
#endif
}