All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
vexconfig.h
Go to the documentation of this file.
1 /*-----------------------------------------------------------------------------*/
2 /* */
3 /* Copyright (c) James Pearman */
4 /* 2013 */
5 /* All Rights Reserved */
6 /* */
7 /*-----------------------------------------------------------------------------*/
8 /* */
9 /* Module: vexconfig.h */
10 /* Author: James Pearman */
11 /* Created: 10 May 2013 */
12 /* */
13 /* Revisions: */
14 /* V1.00 4 July 2013 - Initial release */
15 /* */
16 /*-----------------------------------------------------------------------------*/
17 /* */
18 /* This file is part of ConVEX. */
19 /* */
20 /* The author is supplying this software for use with the VEX cortex */
21 /* control system. ConVEX is free software; you can redistribute it */
22 /* and/or modify it under the terms of the GNU General Public License */
23 /* as published by the Free Software Foundation; either version 3 of */
24 /* the License, or (at your option) any later version. */
25 /* */
26 /* ConVEX is distributed in the hope that it will be useful, */
27 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
28 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
29 /* GNU General Public License for more details. */
30 /* */
31 /* You should have received a copy of the GNU General Public License */
32 /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
33 /* */
34 /* A special exception to the GPL can be applied should you wish to */
35 /* distribute a combined work that includes ConVEX, without being obliged */
36 /* to provide the source code for any proprietary components. */
37 /* See the file exception.txt for full details of how and when the */
38 /* exception can be applied. */
39 /* */
40 /* The author can be contacted on the vex forums as jpearman */
41 /* or electronic mail using jbpearman_at_mac_dot_com */
42 /* Mentor for team 8888 RoboLancers, Pasadena CA. */
43 /* */
44 /*-----------------------------------------------------------------------------*/
45 
46 #ifndef __VEXCONFIG__
47 #define __VEXCONFIG__
48 
49 /*-----------------------------------------------------------------------------*/
50 /** @file vexconfig.h
51  * @brief Cortex configuration macros and prototypes
52 *//*---------------------------------------------------------------------------*/
53 
54 /*-----------------------------------------------------------------------------*/
55 /** @brief Sensor types for cortex configuration */
56 /*-----------------------------------------------------------------------------*/
57 
58 typedef enum {
66 
67  kVexSensorPotentiometer, // not used yet
70 
71 /*-----------------------------------------------------------------------------*/
72 /** @brief A digital pin can be of the following type */
73 /*-----------------------------------------------------------------------------*/
74 /** @details
75  * Although a digital IO pin can in reality only be configured as either an input
76  * or output, they can also have additional functionality depending on the
77  * intended function, for example, a quad encoder uses two digital pins, both
78  * are inputs but we also define them as QuadEnc1 or QuadEnc2
79  */
80 typedef enum {
87 
90 
91 /*-----------------------------------------------------------------------------*/
92 /** @brief Structure holding information to configure a single digital pin */
93 /*-----------------------------------------------------------------------------*/
94 
95 typedef struct _vexDigiCfg {
96  tVexDigitalPin pin; ///< The pin number
97  tVexSensorType type; ///< Type of pin, quad enc, sonar etc.
98  tVexDigitalConfig cfg; ///< The config for this pin, this is type dependent
99  uint16_t chan; ///< The channel for this pin, quad enc & sonars
100 } vexDigiCfg;
101 
102 /*-----------------------------------------------------------------------------*/
103 /** @brief Macro to calculate the number of entries in digital config */
104 /*-----------------------------------------------------------------------------*/
105 #define DIG_CONFIG_SIZE( x ) sizeof( x ) / sizeof( vexDigiCfg )
106 
107 /*-----------------------------------------------------------------------------*/
108 /** @brief Structure holding information to configure a single motor */
109 /*-----------------------------------------------------------------------------*/
110 
111 typedef struct _vexMotorCfg {
112  tVexMotor port; ///< The motor port number (0 through 9)
113  tVexMotorType mtype; ///< Type of motor, 393, 269 etc.
114  bool_t reversed; ///< Motor is reversed if true
115  tVexSensorType stype; ///< Sensor type used for motor position
116  int16_t channel; ///< The above sensor channel
117 } vexMotorCfg;
118 
119 /*-----------------------------------------------------------------------------*/
120 /** @brief Macro to calculate the number of entries in motor config */
121 /*-----------------------------------------------------------------------------*/
122 #define MOT_CONFIG_SIZE( x ) sizeof( x ) / sizeof( vexMotorCfg )
123 
124 
125 #ifdef __cplusplus
126 extern "C" {
127 #endif
128 
129 void vexDigitalConfigure( vexDigiCfg *cfg, int16_t cfg_num );
130 void vexMotorConfigure( vexMotorCfg *cfg, int16_t cfg_num );
131 
134 uint16_t vexDigitalChannelGet( tVexDigitalPin pin );
135 uint16_t vexDigitalCfgGet( tVexDigitalPin pin );
136 
137 #ifdef __cplusplus
138 }
139 #endif
140 
141 #endif // __VEXCONFIG__