All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
vex.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: vex.h */
10 /* Author: James Pearman */
11 /* Created: 7 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 __VEX__
47 #define __VEX__
48 
49 /*-----------------------------------------------------------------------------*/
50 /** @file vex.h
51  * @brief Main vex include file
52 *//*---------------------------------------------------------------------------*/
53 
54 #include <stdarg.h>
55 
56 // Must come first - contains compatibility definitions
57 #include "vexcompat.h"
58 
59 #include "vexanalog.h"
60 #include "vexdigital.h"
61 #include "vexencoder.h"
62 #include "vexsonar.h"
63 #include "vexmotor.h"
64 #include "vexime.h"
65 #include "vexconfig.h"
66 #include "vexspi.h"
67 #include "vexlcd.h"
68 #include "vexctl.h"
69 #include "vexaudio.h"
70 #include "vexsensor.h"
71 #include "vexprintf.h"
72 #include "vexshell.h"
73 #include "vexbkup.h"
74 
75 /**
76  * @brief ConVEX version string.
77  */
78 #define CONVEX_VERSION "1.0.4"
79 
80 /**
81  * @name ConVEX version
82  * @{
83  */
84 /**
85  * @brief ConVEX version major number.
86  */
87 #define CONVEX_MAJOR 1
88 
89 /**
90  * @brief ConVEX version minor number.
91  */
92 #define CONVEX_MINOR 0
93 
94 /**
95  * @brief ConVEX version patch number.
96  */
97 #define CONVEX_PATCH 4
98 /** @} */
99 
100 // ChibiOS version as a hex number, eg. 2.6.1 becomes 0x261
101 #define CH_KERNEL_VERSION_HEX ((CH_KERNEL_MAJOR << 8) | (CH_KERNEL_MINOR << 4) | (CH_KERNEL_PATCH))
102 
103 /*-----------------------------------------------------------------------------*/
104 /** @{ */
105 /** @name task priorities */
106 /*-----------------------------------------------------------------------------*/
107 #define SYSTEM_THREAD_PRIORITY NORMALPRIO + 10
108 #define IME_THREAD_PRIORITY NORMALPRIO + 9
109 #define MONITOR_THREAD_PRIORITY NORMALPRIO + 8
110 #define SONAR_THREAD_PRIORITY NORMALPRIO + 8
111 #define LCD_THREAD_PRIORITY NORMALPRIO
112 #define USER_THREAD_PRIORITY NORMALPRIO + 1
113 /** @} */
114 
115 /*-----------------------------------------------------------------------------*/
116 /** @{ */
117 /** @name Stack sizes */
118 /*-----------------------------------------------------------------------------*/
119 #define USER_TASK_STACK_SIZE 512
120 #define IME_TASK_STACK_SIZE 0x1D0
121 #define SONAR_TASK_STACK_SIZE 0xD0
122 #define LCD_TASK_STACK_SIZE 0xD0
123 #define TEST_TASK_STACK_SIZE 0xD0
124 #define SYSTEM_TASK_STACK_SIZE 0xD0
125 #define MONITOR_TASK_STACK_SIZE 0x1D0
126 #define AUDIO_TASK_STACK_SIZE 0xD0
127 /** @} */
128 
129 /*-----------------------------------------------------------------------------*/
130 // Serial ports swap around depending on the board
131 #ifdef BOARD_OLIMEX_STM32_P103
132 #define SD_CONSOLE &SD2
133 #define SD_LCD1 &SD1
134 #else
135 #define SD_CONSOLE &SD1
136 #define SD_LCD1 &SD2
137 #endif
138 
139 #define SD_LCD2 &SD3
140 
141 /*-----------------------------------------------------------------------------*/
142 
143 #ifdef __cplusplus
144 extern "C" {
145 #endif
146 
147 /*-----------------------------------------------------------------------------*/
148 // Competition top level tasks and functions
149 void vexUserSetup(void) __attribute__ ((weak));
150 void vexUserInit( void ) __attribute__ ((weak));
151 msg_t vexAutonomous( void *arg );
152 msg_t vexOperator( void *arg );
153 
154 /*-----------------------------------------------------------------------------*/
155 // System related functions
156 void vexCortexInit( void );
157 void vexConsoleInit( void );
158 void vexTaskRegister( char *name );
159 void vexTaskRegisterPersistant(char *name, bool_t p );
160 bool_t vexTaskIsRegistered( Thread *tp );
161 bool_t vexTaskPersistentGet( Thread *tp );
162 void vexTaskPersistentSet( Thread *tp, bool_t p );
163 
164 void vexTaskEmergencyStop( void );
165 void vexSleep( int32_t msec );
166 
167 //#define VEX_WATCHDOG_ENABLE 1
168 void vexWatchdogInit(void);
169 inline void vexWatchdogReload(void);
170 int16_t vexWatchdogResetFlagGet(void);
171 
172 /*-----------------------------------------------------------------------------*/
173 // used for trying out code
174 void vexTest( void );
175 void vexTestDebug(vexStream *chp, int argc, char *argv[]);
176 void vexServiceEncoder( short source, short pa, short pb, long *encoder );
177 
178 #ifdef __cplusplus
179 }
180 #endif
181 
182 #endif // __VEX__