upm
1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
|
An example using analog mode
Interesting An example using UART mode
Interesting
Go to the source code of this file.
Data Structures | |
struct | _urm37_context |
Functions | |
urm37_context | urm37_init (int a_pin, int reset_pin, int trigger_pin, float a_ref, int uart, bool analog_mode) |
void | urm37_close (urm37_context dev) |
upm_result_t | urm37_reset (urm37_context dev) |
upm_result_t | urm37_get_distance (urm37_context dev, float *distance, int degrees) |
upm_result_t | urm37_get_temperature (urm37_context dev, float *temperature) |
upm_result_t | urm37_read_eeprom (urm37_context dev, uint8_t addr, uint8_t *value) |
upm_result_t | urm37_write_eeprom (urm37_context dev, uint8_t addr, uint8_t value) |
upm_result_t | urm37_send_command (urm37_context dev, char *cmd, char *response) |
Typedefs | |
typedef struct _urm37_context * | urm37_context |
urm37_context urm37_init | ( | int | a_pin, |
int | reset_pin, | ||
int | trigger_pin, | ||
float | a_ref, | ||
int | uart, | ||
bool | analog_mode | ||
) |
URM37 Initializer
a_pin | Analog pin to use. Ignored in UART mode. |
reset_pin | GPIO pin to use for reset |
trigger_pin | GPIO pin to use for triggering a distance measurement. Ignored in UART mode. |
a_ref | The analog reference voltage. Ignored in UART mode. |
uart | Default UART to use (0 or 1). Ignored in analog mode. |
mode | true for analog mode, false otherwise. |
void urm37_close | ( | urm37_context | dev | ) |
URM37 sensor close function
upm_result_t urm37_reset | ( | urm37_context | dev | ) |
Reset the device. This will take approximately 3 seconds to complete.
dev | sensor context |
upm_result_t urm37_get_distance | ( | urm37_context | dev, |
float * | distance, | ||
int | degrees | ||
) |
Get the distance measurement. A return value of 65535.0 in UART mode indicates an invalid measurement.
dev | sensor context |
distance | A pointer to a float that will contain the distance in CM if the measurement is successful. |
degrees | In UART mode, this specifies the degrees to turn an attached PWM servo connected to the MOTO output on the URM37. Valid values are 0-270. This option is ignored in analog mode. If you are not using this functionality, just pass 0. |
upm_result_t urm37_get_temperature | ( | urm37_context | dev, |
float * | temperature | ||
) |
Get the temperature measurement. This is only valid in UART mode.
dev | sensor context |
temperature | A float pointer containing the measured temperature in degrees C |
upm_result_t urm37_read_eeprom | ( | urm37_context | dev, |
uint8_t | addr, | ||
uint8_t * | value | ||
) |
In UART mode only, read a value from the EEPROM and return it.
dev | sensor context |
addr | The address in the EEPROM to read. Valid values are between 0x00-0x04. |
value | A pointer containing the returned value. |
upm_result_t urm37_write_eeprom | ( | urm37_context | dev, |
uint8_t | addr, | ||
uint8_t | value | ||
) |
In UART mode only, write a value into an address on the EEPROM.
dev | sensor context |
addr | The address in the EEPROM to write. Valid values are between 0x00-0x04. |
value | The value to write |
upm_result_t urm37_send_command | ( | urm37_context | dev, |
char * | cmd, | ||
char * | response | ||
) |
In UART mode only, send a 4-byte command, and return a 4-byte response.
dev | sensor context |
cmd | A 4-byte command to transmit |
response | The 4-byte response |
typedef struct _urm37_context * urm37_context |
device context