upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
wfs.h
Go to the documentation of this file.
1 /*
2  * Author: Jon Trulson <jtrulson@ics.com>
3  * Copyright (c) 2017 Intel Corporation.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 #pragma once
25 
26 
27 #include <stdint.h>
28 #include <stdlib.h>
29 #include <unistd.h>
30 
31 #include <upm.h>
32 #include <upm_utilities.h>
33 #include <mraa/gpio.h>
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
49  typedef struct _wfs_context {
50  mraa_gpio_context gpio;
51 
52  volatile uint32_t flowCounter;
53  upm_clock_t clock;
54  bool isrInstalled;
55  } *wfs_context;
56 
64  wfs_context wfs_init(int pin);
65 
71  void wfs_close(wfs_context dev);
72 
80  uint32_t wfs_get_millis(const wfs_context dev);
81 
87  void wfs_init_clock(const wfs_context dev);
88 
95  void wfs_clear_flow_counter(const wfs_context dev);
96 
103  upm_result_t wfs_start_flow_counter(const wfs_context dev);
104 
110  void wfs_stop_flow_counter(const wfs_context dev);
111 
118  uint32_t wfs_flow_counter(const wfs_context dev);
119 
129  float wfs_flow_rate(const wfs_context dev);
130 
131 
132 #ifdef __cplusplus
133 }
134 #endif
upm_result_t wfs_start_flow_counter(const wfs_context dev)
Definition: wfs.c:108
void wfs_clear_flow_counter(const wfs_context dev)
Definition: wfs.c:101
uint32_t wfs_flow_counter(const wfs_context dev)
Definition: wfs.c:136
void wfs_init_clock(const wfs_context dev)
Definition: wfs.c:87
uint32_t wfs_get_millis(const wfs_context dev)
Definition: wfs.c:94
float wfs_flow_rate(const wfs_context dev)
Definition: wfs.c:143
struct _wfs_context * wfs_context
void wfs_stop_flow_counter(const wfs_context dev)
Definition: wfs.c:126
wfs_context wfs_init(int pin)
Definition: wfs.c:41
void wfs_close(wfs_context dev)
Definition: wfs.c:74
Definition: wfs.h:49