-
Notifications
You must be signed in to change notification settings - Fork 2
/
sensors.h
132 lines (102 loc) · 4.09 KB
/
sensors.h
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/****************************************************************************
* XLP 16-bit Dev board Sensor handling & processing header file
*****************************************************************************
* FileName: sensors.h
* Dependencies: system.h
* Processor: PIC24F16KA102
* Hardware: XLP 16-bit Development Board
* Complier: Microchip C30 v3.10 or higher
* Company: Microchip Technology, Inc.
*
* Copyright and Disclaimer Notice
*
* Copyright ©2007-2008 Microchip Technology Inc. All rights reserved.
*
* Microchip licenses to you the right to use, modify, copy and distribute
* Software only when embedded on a Microchip microcontroller or digital
* signal controller and used with a Microchip radio frequency transceiver,
* which are integrated into your product or third party product (pursuant
* to the terms in the accompanying license agreement).
*
* You should refer to the license agreement accompanying this Software for
* additional information regarding your rights and obligations.
*
* SOFTWARE AND DOCUMENTATION ARE PROVIDED “AS IS?WITHOUT WARRANTY OF ANY
* KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY
* WARRANTY OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE. IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE
* LIABLE OR OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY,
* CONTRIBUTION, BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY ANY
* DIRECT OR INDIRECT DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO
* ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES,
* LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF SUBSTITUTE GOODS,
* TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT
* NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
*
* Author Date Comment
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Brant Ivey 4/1/10 New header created to improve code organization
*****************************************************************************/
#ifndef _SENSORS_H
#define _SENSORS_H
/****************************************************************************
Section: Includes
***************************************************************************/
#include "system.h"
#define MAG_ADDRESS 0x3C
#define GYRO_ADDRESS 0xD2
#define ACC_ADDRESS 0x3A
#define I2C_WRITE 0x00
#define I2C_READ 0x01
#define HMC5883_ModeRegisterAddress 0x02
#define HMC5883_ContinuousModeCommand 0x00
#define HMC5883_ConfARegisterAddress 0x00
#define HMC5883_ConfBRegisterAddress 0x01
#define HMC5883_75HzCommand 0x18
#define L3G4200_CTRL_REG1 0x20
#define L3G4200_CTRL_REG1_SET 0x7F
#define L3G4200_CTRL_REG2 0x21
#define L3G4200_CTRL_REG2_SET 0x20
#define L3G4200_CTRL_REG3 0x22
#define L3G4200_CTRL_REG3_SET 0x00
#define L3G4200_CTRL_REG4 0x23
#define L3G4200_CTRL_REG4_SET 0x10
#define L3G4200_CTRL_REG5 0x24
#define L3G4200_CTRL_REG5_SET 0x00
#define L3G4200_OUT_TEMP 0x26
#define L3G4200_CONTINUOUS_READ 0x80
#define L3G4200_X_L 0x28
#define L3G4200_FIFO_CTRL_REG 0x2E
#define L3G4200_FIFO_CTRL_REG_SET 0x00
#define MMA8451Q_F_SETUP 0x09
#define MMA8451Q_F_SETUP_SET 0x00
#define MMA8451Q_TRIG_CFG 0x0A
#define MMA8451Q_TRIG_CFG_SET 0x00
#define MMA8451Q_XYZ_DATA_CFG 0x0E
#define MMA8451Q_XYZ_DATA_CFG_SET 0x02
#define MMA8451Q_FF_MT_CFG 0x15
#define MMA8451Q_FF_MT_CFG_SET 0x78
#define MMA8451Q_FF_MT_THS 0x17
#define MMA8451Q_FF_MT_THS_SET 0x00
#define MMA8451Q_CTRL_REG1 0x2A
#define MMA8451Q_CTRL_REG1_SET 0x01
#define MMA8451Q_CTRL_REG2 0x2B
#define MMA8451Q_CTRL_REG2_SET 0x02
#define MMA8451Q_CTRL_REG3 0x2C
#define MMA8451Q_CTRL_REG3_SET 0x00
#define MMA8451Q_CTRL_REG4 0x2D
#define MMA8451Q_CTRL_REG4_SET 0x00
#define MMA8451Q_CTRL_REG5 0x2E
#define MMA8451Q_CTRL_REG5_SET 0x00
#define GYRO_OUT_EN
#define MAG_OUT_EN
#define ACC_OUT_EN
void ReadGyro(BYTE *pGyroData);
void ReadMag(BYTE *pMagData);
void ReadAcc(BYTE *pAccData);
void configGyro(BYTE subaddr, BYTE value);
void configAcc(BYTE subaddr, BYTE value);
void SetupGyro(void);
void SetupMag(void);
void SetupAcc(void);
#endif