All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
vexsonar.h File Reference

Ultrasonic distance sensor driver macros and prototypes. More...

Go to the source code of this file.

Data Structures

struct  _vexSonar_t
 Holds information relating to a sonar. More...
 

Typedefs

typedef struct _vexSonar_t vexSonar_t
 Holds information relating to a sonar. More...
 

Enumerations

enum  tVexSonarChannel {
  kVexSonar_1 = 0, kVexSonar_2, kVexSonar_3, kVexSonar_4,
  kVexSonar_5, kVexSonar_Num
}
 Sonar channel number. More...
 

Functions

void vexSonarAdd (tVexSonarChannel channel, tVexDigitalPin pa, tVexDigitalPin pb)
 Add a sonar to the array of installed sonars. More...
 
void vexSonarStart (tVexSonarChannel channel)
 Start a sonar by enabling the interrupt port. More...
 
void vexSonarStop (tVexSonarChannel channel)
 Stop a sonar by disabling the interrupt port. More...
 
void vexSonarStartAll (void)
 Enable all installed sonars. More...
 
void vexSonarPing (tVexSonarChannel channel)
 Start 10uS pulse to initiate sonar ping. More...
 
void vexSonarDebug (vexStream *chp, int argc, char *argv[])
 Send useful information to debug console. More...
 
void vexSonarRun (void)
 Start the sonar polling task if at least one sonar is installed. More...
 
int16_t vexSonarGetCm (tVexSonarChannel channel)
 Get sonar value in cm. More...
 
int16_t vexSonarGetInch (tVexSonarChannel channel)
 Get sonar value in inches. More...
 

Detailed Description

Ultrasonic distance sensor driver macros and prototypes.

Typedef Documentation

typedef struct _vexSonar_t vexSonar_t

Holds information relating to a sonar.

Note
pin refers to the digital pin 1 through 12, port refers to the STM32 port, GPIOA, GPIOB etc. pad refers to the bit on the digital port 0 through 15

Enumeration Type Documentation

Sonar channel number.

Enumerator
kVexSonar_1 
kVexSonar_2 
kVexSonar_3 
kVexSonar_4 
kVexSonar_5 
kVexSonar_Num 

Function Documentation

void vexSonarAdd ( tVexSonarChannel  channel,
tVexDigitalPin  pa,
tVexDigitalPin  pb 
)

Add a sonar to the array of installed sonars.

Parameters
[in]channelThe sonar channel
[in]paThe first input pin used by the sonar
[in]pbThe second input pin used by the sonat
void vexSonarStart ( tVexSonarChannel  channel)

Start a sonar by enabling the interrupt port.

Parameters
[in]channelThe sonar channel
void vexSonarStop ( tVexSonarChannel  channel)

Stop a sonar by disabling the interrupt port.

Parameters
[in]channelThe sonar channel
void vexSonarStartAll ( void  )

Enable all installed sonars.

void vexSonarPing ( tVexSonarChannel  channel)

Start 10uS pulse to initiate sonar ping.

Parameters
[in]channelThe sonar channel
Note
Internal sonar driver function
void vexSonarDebug ( vexStream chp,
int  argc,
char *  argv[] 
)

Send useful information to debug console.

Parameters
[in]chpA pointer to a vexStream object
[in]argcThe number of command line arguments
[in]argvAn array of pointers to the command line args
void vexSonarRun ( void  )

Start the sonar polling task if at least one sonar is installed.

int16_t vexSonarGetCm ( tVexSonarChannel  channel)

Get sonar value in cm.

Parameters
[in]channelThe sonar channel
Returns
The distance in cm
int16_t vexSonarGetInch ( tVexSonarChannel  channel)

Get sonar value in inches.

Parameters
[in]channelThe sonar channel
Returns
The distance in inches