Paparazzi UAS  v4.0.4_stable-3-gf39211a
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
VN100.h
Go to the documentation of this file.
1 /*
2  * Paparazzi $Id: $
3  *
4  * Copyright (C) 2010 ENAC
5  *
6  * This file is part of paparazzi.
7  *
8  * paparazzi is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2, or (at your option)
11  * any later version.
12  *
13  * paparazzi is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with paparazzi; see the file COPYING. If not, write to
20  * the Free Software Foundation, 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  *
23  */
24 
30 #ifndef VN100_H
31 #define VN100_H
32 
33 #include "std.h"
34 
35 /* VN-100 Registers */
36 #define VN100_REG_MODEL 1
37 #define VN100_REG_HWREV 2
38 #define VN100_REG_SN 3
39 #define VN100_REG_FWVER 4
40 #define VN100_REG_SBAUD 5
41 #define VN100_REG_ADOR 6
42 #define VN100_REG_ADOF 7
43 #define VN100_REG_YPR 8
44 #define VN100_REG_QTN 9
45 #define VN100_REG_QTM 10
46 #define VN100_REG_QTA 11
47 #define VN100_REG_QTR 12
48 #define VN100_REG_QMA 13
49 #define VN100_REG_QAR 14
50 #define VN100_REG_QMR 15
51 #define VN100_REG_DCM 16
52 #define VN100_REG_MAG 17
53 #define VN100_REG_ACC 18
54 #define VN100_REG_GYR 19
55 #define VN100_REG_MAR 20
56 #define VN100_REG_REF 21
57 #define VN100_REG_SIG 22
58 #define VN100_REG_HSI 23
59 #define VN100_REG_ATP 24
60 #define VN100_REG_ACT 25
61 #define VN100_REG_RFR 26
62 #define VN100_REG_YMR 27
63 #define VN100_REG_ACG 28
64 
65 /* Data Size */
66 #define VN100_REG_MODEL_SIZE 12
67 #define VN100_REG_HWREV_SIZE 4
68 #define VN100_REG_SN_SIZE 12
69 #define VN100_REG_FWVER_SIZE 4
70 #define VN100_REG_SBAUD_SIZE 4
71 #define VN100_REG_ADOR_SIZE 4
72 #define VN100_REG_ADOF_SIZE 4
73 #define VN100_REG_YPR_SIZE (3*4)
74 #define VN100_REG_QTN_SIZE (4*4)
75 #define VN100_REG_QTM_SIZE (7*4)
76 #define VN100_REG_QTA_SIZE (7*4)
77 #define VN100_REG_QTR_SIZE (7*4)
78 #define VN100_REG_QMA_SIZE (10*4)
79 #define VN100_REG_QAR_SIZE (10*4)
80 #define VN100_REG_QMR_SIZE (13*4)
81 #define VN100_REG_DCM_SIZE (9*4)
82 #define VN100_REG_MAG_SIZE (3*4)
83 #define VN100_REG_ACC_SIZE (3*4)
84 #define VN100_REG_GYR_SIZE (3*4)
85 #define VN100_REG_MAR_SIZE (9*4)
86 #define VN100_REG_REF_SIZE (6*4)
87 #define VN100_REG_SIG_SIZE (10*4)
88 #define VN100_REG_HSI_SIZE (12*4)
89 #define VN100_REG_ATP_SIZE (4*4)
90 #define VN100_REG_ACT_SIZE (12*4)
91 #define VN100_REG_RFR_SIZE (9*4)
92 #define VN100_REG_YMR_SIZE (12*4)
93 #define VN100_REG_ACG_SIZE 4
94 
95 #define VN100_DataSizeOfReg(_r) (_r##_SIZE)
96 
97 /* Command IDs */
98 #define VN100_CmdID_ReadRegister 0x01
99 #define VN100_CmdID_WriteRegister 0x02
100 #define VN100_CmdID_WriteSettings 0x03
101 #define VN100_CmdID_RestoreFactorySettings 0x04
102 #define VN100_CmdID_Tare 0x05
103 #define VN100_CmdID_Reset 0x06
104 
105 /* System Error */
106 #define VN100_Error_None 0
107 #define VN100_Error_HardFaultException 1
108 #define VN100_Error_InputBufferOverflow 2
109 #define VN100_Error_InvalidChecksum 3
110 #define VN100_Error_InvalidCommand 4
111 #define VN100_Error_NotEnoughParameters 5
112 #define VN100_Error_TooManyParameters 6
113 #define VN100_Error_InvalidParameter 7
114 #define VN100_Error_InvalidRegister 8
115 #define VN100_Error_UnauthorizedAccess 9
116 #define VN100_Error_WatchdogReset 10
117 #define VN100_Error_OutputBufferOverflow 11
118 #define VN100_Error_InsufficientBandwidth 12
119 
120 /* Asynchronous Data Output Register */
121 #define VN100_ADOR_OFF 0
122 #define VN100_ADOR_YPR 1
123 #define VN100_ADOR_QTN 2
124 #define VN100_ADOR_QTM 3
125 #define VN100_ADOR_QTA 4
126 #define VN100_ADOR_QTR 5
127 #define VN100_ADOR_QMA 6
128 #define VN100_ADOR_QAR 7
129 #define VN100_ADOR_QMR 8
130 #define VN100_ADOR_DCM 9
131 #define VN100_ADOR_MAG 10
132 #define VN100_ADOR_ACC 11
133 #define VN100_ADOR_GYR 12
134 #define VN100_ADOR_MAR 13
135 #define VN100_ADOR_YMR 14
136 #define VN100_ADOR_RAB 251
137 #define VN100_ADOR_RAW 252
138 #define VN100_ADOR_CMV 253
139 #define VN100_ADOR_STV 254
140 #define VN100_ADOR_COV 255
141 
142 /* Asynchronous Data Ouput Rate Register */
143 #define VN100_ADOF_1HZ 1
144 #define VN100_ADOF_2HZ 2
145 #define VN100_ADOF_4HZ 4
146 #define VN100_ADOF_5HZ 5
147 #define VN100_ADOF_10HZ 10
148 #define VN100_ADOF_20HZ 20
149 #define VN100_ADOF_25HZ 25
150 #define VN100_ADOF_40HZ 40
151 #define VN100_ADOF_50HZ 50
152 #define VN100_ADOF_100HZ 100
153 #define VN100_ADOF_200HZ 200
154 
155 /* Serial Baud Rate Register */
156 #define VN100_Baud_9600 9600
157 #define VN100_Baud_19200 19200
158 #define VN100_Baud_38400 38400
159 #define VN100_Baud_57600 57600
160 #define VN100_Baud_115200 115200
161 #define VN100_Baud_128000 128000
162 #define VN100_Baud_230400 230400
163 #define VN100_Baud_460800 460800
164 #define VN100_Baud_921600 921600
165 
166 /* Accelerometer Gain Type */
167 #define VN100_AccGain_2G 0
168 #define VN100_AccGain_6G 1
169 
170 /* 32-bit Parameter Type */
171 typedef union {
173  float Float;
174 } VN100_Param;
175 
176 /* SPI Buffer size */
177 #define VN100_SPI_BUFFER_SIZE 48
178 
179 /* SPI Request Packet */
180 typedef struct {
187 
188 /* SPI Response Packet */
189 typedef struct {
196 
197 #define VN100_Packet_SetBaud(_b) { VN100_CmdID_WriteRegister, VN100_REG_SBAUD, 0, 0, { _b } }
198 #define VN100_Packet_SetADOR(_r) { VN100_CmdID_WriteRegister, VN100_REG_ADOR, 0, 0, { _r } }
199 #define VN100_Packet_SetaDOF(_f) { VN100_CmdID_WriteRegister, VN100_REG_ADOF, 0, 0, { _f } }
200 
201 #define VN100_BytesOfWord(_w) { (uint8_t)(_w & 0xFF), (uint8_t)((_w & (0xFF<<8))>>8), (uint8_t)((_w & (0xFF<<16))>>16), (uint8_t)((_w & (0xFF<<24))>>24) }
202 #define VN100_WordOfBytes(_b) (((uint32_t)(_b[3])<<24)|((uint32_t)(_b[2])<<16)|((uint16_t)(_b[1])<<8)|(uint16_t)(_b[0]))
203 
204 #endif
uint8_t RegID
Definition: VN100.h:192
uint32_t UInt
Definition: VN100.h:172
#define VN100_SPI_BUFFER_SIZE
Definition: VN100.h:177
float Float
Definition: VN100.h:173
uint8_t ErrID
Definition: VN100.h:193
uint8_t ZeroByte
Definition: VN100.h:190
uint8_t CmdID
Definition: VN100.h:181
uint8_t ZeroByte2
Definition: VN100.h:184
unsigned long uint32_t
Definition: types.h:18
uint8_t RegID
Definition: VN100.h:182
unsigned char uint8_t
Definition: types.h:14
uint8_t CmdID
Definition: VN100.h:191
uint8_t ZeroByte1
Definition: VN100.h:183