Main Page
Related Pages
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
vexsonar.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: vexsonar.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 __VEXSONAR__
47
#define __VEXSONAR__
48
49
/*-----------------------------------------------------------------------------*/
50
/** @file vexsonar.h
51
* @brief Ultrasonic distance sensor driver macros and prototypes
52
*/
/*---------------------------------------------------------------------------*/
53
54
/*-----------------------------------------------------------------------------*/
55
/** @brief Sonar channel number */
56
/*-----------------------------------------------------------------------------*/
57
typedef
enum
{
58
kVexSonar_1
= 0,
59
kVexSonar_2
,
60
kVexSonar_3
,
61
kVexSonar_4
,
62
kVexSonar_5
,
63
64
kVexSonar_Num
65
}
tVexSonarChannel
;
66
67
/*-----------------------------------------------------------------------------*/
68
/** @brief Holds information relating to a sonar */
69
/*-----------------------------------------------------------------------------*/
70
/** @note
71
* pin refers to the digital pin 1 through 12, port refers to the
72
* STM32 port, GPIOA, GPIOB etc. pad refers to the bit on the digital port
73
* 0 through 15
74
*/
75
76
typedef
struct
_vexSonar_t
{
77
uint16_t
time_r
;
///< time of rising edge on receive pulse
78
uint16_t
time_f
;
///< time of falling edge on receive pulse
79
int32_t
time
;
///< receive pulse time
80
int16_t
distance_cm
;
///< distance calculated as cm
81
int16_t
distance_inch
;
///< distance calculated as inches
82
int16_t
flags
;
///< flags, SONAR_INSTALLED & SONAR_ENABLED
83
tVexDigitalPin
pa
;
///< Sonar digital pin a
84
tVexDigitalPin
pb
;
///< Sonar digital pin b
85
ioportid_t
pa_port
;
///< Sonar GPIO port a
86
int16_t
pa_pad
;
///< Sonar GPIO pad a
87
ioportid_t
pb_port
;
///< Sonar GPIO port b
88
int16_t
pb_pad
;
///< Sonar GPIO pad b
89
}
vexSonar_t
;
90
91
#ifdef __cplusplus
92
extern
"C"
{
93
#endif
94
95
void
vexSonarAdd
(
tVexSonarChannel
channel,
tVexDigitalPin
pa,
tVexDigitalPin
pb );
96
void
vexSonarStart
(
tVexSonarChannel
channel );
97
void
vexSonarStop
(
tVexSonarChannel
channel );
98
void
vexSonarStartAll
(
void
);
99
void
vexSonarPing
(
tVexSonarChannel
channel);
100
void
vexSonarDebug
(
vexStream
*chp,
int
argc,
char
*argv[]);
101
void
vexSonarRun
(
void
);
102
int16_t
vexSonarGetCm
(
tVexSonarChannel
channel );
103
int16_t
vexSonarGetInch
(
tVexSonarChannel
channel );
104
105
#ifdef __cplusplus
106
}
107
#endif
108
109
110
#endif // __VEXSONAR__
convex
cortex
fw
vexsonar.h
Generated on Sun Jan 5 2014 15:43:37 for Convex by
1.8.4