C++ DevKit
C++ set of OOP library
Loading...
Searching...
No Matches
rtos_hc_sr04.h
Go to the documentation of this file.
1
11#pragma once
12
13#include "pico/stdlib.h"
14#include "FreeRTOS.h"
15#include "task.h"
16#include "queue.h"
17
20{
24 uint32_t event_mask;
25};
26
32{
33private:
41 QueueHandle_t input_timer_queue;
43 QueueHandle_t output_range_queue;
46
47public:
48
56 rtos_HCSR04(uint trig_pin, uint echo_pin,
57 QueueHandle_t input_timer_queue, QueueHandle_t output_range_queue,
58 gpio_irq_callback_t echo_irq_call_back, uint32_t event_mask_config = GPIO_IRQ_EDGE_FALL | GPIO_IRQ_EDGE_RISE);
59
61 void get_distance();
62};
uint32_t echo_irq_mask_config
A memory slot reserved to store the irq_event_mask.
Definition rtos_hc_sr04.h:39
uint trig_pin
the GPIO pin that send trigger signal to the HC-SR04 module
Definition rtos_hc_sr04.h:35
QueueHandle_t input_timer_queue
the queue from which echo time measurement are received
Definition rtos_hc_sr04.h:41
uint echo_pin
the GPIO pin where the HC-SR04 return echo signal
Definition rtos_hc_sr04.h:37
QueueHandle_t output_range_queue
the queue to which the resulting range is sent
Definition rtos_hc_sr04.h:43
bool measure_completed
Flag indicating if the measurement is completed.
Definition rtos_hc_sr04.h:45
void get_distance()
request a measure from HCSR04
Definition rtos_hc_sr04.cpp:26
rtos_HCSR04(uint trig_pin, uint echo_pin, QueueHandle_t input_timer_queue, QueueHandle_t output_range_queue, gpio_irq_callback_t echo_irq_call_back, uint32_t event_mask_config=GPIO_IRQ_EDGE_FALL|GPIO_IRQ_EDGE_RISE)
Construct a new rtos_HCSR04 object.
Definition rtos_hc_sr04.cpp:8
data structure used by ISR to capture, mask, time.
Definition rtos_hc_sr04.h:20
uint32_t current_time_us
the current time at wich the IRQ occurred
Definition rtos_hc_sr04.h:22
uint32_t event_mask
the IRQ mask given by the IRQ harware
Definition rtos_hc_sr04.h:24