mraa  0.7.1
Low Level Skeleton Library for Communication on GNU/Linux platforms
common.hpp
Go to the documentation of this file.
1 /*
2  * Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
3  * Copyright (c) 2014 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 
25 #pragma once
26 
27 #include "common.h"
28 #include <string>
29 
33 namespace mraa
34 {
35 
54 inline mraa_result_t
56 {
57  return mraa_init();
58 }
59 
65 inline std::string
67 {
68  std::string ret = mraa_get_version();
69  return ret;
70 }
71 
81 inline int
82 setPriority(const unsigned int priority)
83 {
84  return mraa_set_priority(priority);
85 }
86 
92 inline mraa_platform_t
94 {
95  return mraa_get_platform_type();
96 }
97 
103 inline void
105 {
106  mraa_result_print(result);
107 }
108 
116 inline bool
118 {
119  return (bool) mraa_pin_mode_test(pin, mode);
120 }
121 
127 inline unsigned int
129 {
130  return mraa_adc_raw_bits();
131 }
132 
138 inline unsigned int
140 {
141  return mraa_adc_supported_bits();
142 }
143 
149 inline std::string
151 {
152  std::string ret_val(mraa_get_platform_name());
153  return ret_val;
154 }
155 
161 inline unsigned int
163 {
164  return mraa_get_pin_count();
165 }
166 
174 inline std::string
175 getPinName(int pin)
176 {
177  std::string ret_val(mraa_get_pin_name(pin));
178  return ret_val;
179 }
180 
188 inline mraa_result_t
189 setLogLevel(int level)
190 {
191  return mraa_set_log_level(level);
192 }
193 }
mraa_platform_t getPlatformType()
Definition: common.hpp:93
mraa_result_t setLogLevel(int level)
Definition: common.hpp:189
char * mraa_get_platform_name()
const char * mraa_get_version()
std::string getVersion()
Definition: common.hpp:66
mraa_platform_t
Definition: types.h:39
mraa_platform_t mraa_get_platform_type()
mraa_boolean_t mraa_pin_mode_test(int pin, mraa_pinmodes_t mode)
unsigned int mraa_adc_supported_bits()
unsigned int adcSupportedBits()
Definition: common.hpp:139
bool pinModeTest(int pin, mraa_pinmodes_t mode)
Definition: common.hpp:117
char * mraa_get_pin_name(int pin)
unsigned int getPinCount()
Definition: common.hpp:162
mraa_result_t mraa_init() __attribute__((constructor))
std::string getPlatformName()
Definition: common.hpp:150
unsigned int mraa_adc_raw_bits()
mraa_result_t init()
Definition: common.hpp:55
Definition: aio.hpp:30
int setPriority(const unsigned int priority)
Definition: common.hpp:82
mraa_result_t
Definition: types.h:184
mraa_pinmodes_t
Definition: types.h:205
std::string getPinName(int pin)
Definition: common.hpp:175
int mraa_set_priority(const unsigned int priority)
unsigned int adcRawBits()
Definition: common.hpp:128
void mraa_result_print(mraa_result_t result)
mraa_result_t mraa_set_log_level(int level)
void printError(mraa_result_t result)
Definition: common.hpp:104
unsigned int mraa_get_pin_count()