|
Firmware SDK
|
Driver for HC-SR04 ultrasonic range sensor. More...
Typedefs | |
| typedef struct twr_hc_sr04_t | twr_hc_sr04_t |
| HC-SR04 instance. | |
Enumerations | |
| enum | twr_hc_sr04_event_t { TWR_HC_SR04_EVENT_ERROR = 0 , TWR_HC_SR04_EVENT_UPDATE = 1 } |
| enum | twr_hc_sr04_echo_t { TWR_HC_SR04_ECHO_P5 = TWR_GPIO_P5 , TWR_HC_SR04_ECHO_P8 = TWR_GPIO_P8 } |
Functions | |
| void | twr_hc_sr04_init_sensor_module (twr_hc_sr04_t *self) |
| Initialize HC-SR04 for sensor module. More... | |
| void | twr_hc_sr04_init (twr_hc_sr04_t *self, twr_gpio_channel_t trig, twr_hc_sr04_echo_t echo) |
| Initialize HC-SR04. More... | |
| void | twr_hc_sr04_set_event_handler (twr_hc_sr04_t *self, void(*event_handler)(twr_hc_sr04_t *, twr_hc_sr04_event_t, void *), void *event_param) |
| Set callback function. More... | |
| void | twr_hc_sr04_set_update_interval (twr_hc_sr04_t *self, twr_tick_t interval) |
| Set measurement interval. More... | |
| bool | twr_hc_sr04_measure (twr_hc_sr04_t *self) |
| Start measurement manually. More... | |
| bool | twr_hc_sr04_get_distance_millimeter (twr_hc_sr04_t *self, float *millimeter) |
| Get measured distance in millimeters. More... | |
Driver for HC-SR04 ultrasonic range sensor.
| enum twr_hc_sr04_event_t |
| Enumerator | |
|---|---|
| TWR_HC_SR04_EVENT_ERROR | Error event. |
| TWR_HC_SR04_EVENT_UPDATE | Update event. |
Definition at line 12 of file twr_hc_sr04.h.
| bool twr_hc_sr04_get_distance_millimeter | ( | twr_hc_sr04_t * | self, |
| float * | millimeter | ||
| ) |
Get measured distance in millimeters.
| [in] | self | Instance |
| [out] | millimeter | Pointer to variable where result will be stored |
Definition at line 190 of file twr_hc_sr04.c.
| void twr_hc_sr04_init | ( | twr_hc_sr04_t * | self, |
| twr_gpio_channel_t | trig, | ||
| twr_hc_sr04_echo_t | echo | ||
| ) |
Initialize HC-SR04.
| [in] | self | Instance |
| [in] | echo | Pin |
| [in] | trig | Pin |
Definition at line 19 of file twr_hc_sr04.c.
Referenced by twr_hc_sr04_init_sensor_module().


| void twr_hc_sr04_init_sensor_module | ( | twr_hc_sr04_t * | self | ) |
Initialize HC-SR04 for sensor module.
| [in] | self | Instance |
Definition at line 14 of file twr_hc_sr04.c.

| bool twr_hc_sr04_measure | ( | twr_hc_sr04_t * | self | ) |
Start measurement manually.
| [in] | self | Instance |
Definition at line 114 of file twr_hc_sr04.c.
Referenced by twr_hc_sr04_set_update_interval().


| void twr_hc_sr04_set_event_handler | ( | twr_hc_sr04_t * | self, |
| void(*)(twr_hc_sr04_t *, twr_hc_sr04_event_t, void *) | event_handler, | ||
| void * | event_param | ||
| ) |
Set callback function.
| [in] | self | Instance |
| [in] | event_handler | Function address |
| [in] | event_param | Optional event parameter (can be NULL) |
Definition at line 92 of file twr_hc_sr04.c.
| void twr_hc_sr04_set_update_interval | ( | twr_hc_sr04_t * | self, |
| twr_tick_t | interval | ||
| ) |
Set measurement interval.
| [in] | self | Instance |
| [in] | interval | Measurement interval |
Definition at line 98 of file twr_hc_sr04.c.
