stm32f1/lib/sensor_sr04.h

27 lines
933 B
C

/** library to determine range using HC-SR04 ultrasonic range sensor
* @file
* @author King Kévin <kingkevin@cuvoodoo.info>
* @copyright SPDX-License-Identifier: GPL-3.0-or-later
* @date 2020
* @note peripherals used: timer @ref sensor_sr04_timer, GPIO @ref sensor_sr04_gpio
*/
#pragma once
/** distance in mm once an echo has been received
* @note distance set 1 when the object is too near (no echo received)
* @note distance set UINT16_MAX when the object is too far (echo received to late)
* @warning to be clear by user
*/
extern volatile uint16_t sensor_sr04_distance;
/** configure MCU peripherals to communicate with HC-SR04 sensor
*/
void sensor_sr04_setup(void);
/** configure MCU peripherals used to communicate with HC-SR04 sensor
*/
void sensor_sr04_release(void);
/** trigger measurement
* @note the resulting measurement will be set in sensor_sr04_distance
*/
void sensor_sr04_trigger(void);