scoutos / scout / analog / src / analog.h @ 572adceb
History | View | Annotate | Download (2.75 KB)
1 | a826ac0f | Dev Gurjar | /**
|
---|---|---|---|
2 | * Copyright (c) 2011 Colony Project
|
||
3 | *
|
||
4 | * Permission is hereby granted, free of charge, to any person
|
||
5 | * obtaining a copy of this software and associated documentation
|
||
6 | * files (the "Software"), to deal in the Software without
|
||
7 | * restriction, including without limitation the rights to use,
|
||
8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||
9 | * copies of the Software, and to permit persons to whom the
|
||
10 | * Software is furnished to do so, subject to the following
|
||
11 | * 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
|
||
18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||
19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||
20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||
21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||
22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||
23 | * OTHER DEALINGS IN THE SOFTWARE.
|
||
24 | c492be62 | Alex Zirbel | */
|
25 | a826ac0f | Dev Gurjar | |
26 | /**
|
||
27 | * @file analog.h
|
||
28 | * @brief Contains analog declarations and functions.
|
||
29 | *
|
||
30 | * Contains functions and definitions for the use of
|
||
31 | * analog.
|
||
32 | *
|
||
33 | * @author Colony Project, CMU Robotics Club
|
||
34 | * @author Dev Gurjar
|
||
35 | **/
|
||
36 | |||
37 | #ifndef _ANALOG_H_
|
||
38 | #define _ANALOG_H_
|
||
39 | |||
40 | #include "analog/query_analog.h" |
||
41 | |||
42 | /** @brief Analog port 0 **/
|
||
43 | #define AN0 0x00 |
||
44 | /** @brief Analog port 1 **/
|
||
45 | #define AN1 0x01 |
||
46 | /** @brief Analog port 2 **/
|
||
47 | #define AN2 0x02 |
||
48 | /** @brief Analog port 3 **/
|
||
49 | #define AN3 0x03 |
||
50 | /** @brief Analog port 4 **/
|
||
51 | #define AN4 0x04 |
||
52 | /** @brief Analog port 5 **/
|
||
53 | #define AN5 0x05 |
||
54 | /** @brief Analog port 6 **/
|
||
55 | #define AN6 0x06 |
||
56 | /** @brief Analog port 7 **/
|
||
57 | #define AN7 0x07 |
||
58 | /** @brief Analog port 8 **/
|
||
59 | #define AN8 0x08 |
||
60 | /** @brief Analog port 9 **/
|
||
61 | #define AN9 0x09 |
||
62 | /** @brief Analog port 10 **/
|
||
63 | #define AN10 0x0A |
||
64 | /** @brief Analog port 11 **/
|
||
65 | #define AN11 0x0B |
||
66 | /** @brief Analog port 12 **/
|
||
67 | #define AN12 0x0C |
||
68 | /** @brief Analog port 13 **/
|
||
69 | #define AN13 0x0D |
||
70 | /** @brief Analog port 14 **/
|
||
71 | #define AN14 0x0E |
||
72 | /** @brief Analog port 15 **/
|
||
73 | 8e7baefc | Dev Gurjar | #define AN15 0x0F |
74 | a826ac0f | Dev Gurjar | |
75 | /** @brief Struct to hold the value of a particular analog port **/
|
||
76 | 572adceb | Alex Zirbel | typedef struct |
77 | { |
||
78 | a826ac0f | Dev Gurjar | uint8_t adc8; |
79 | uint16_t adc10; |
||
80 | } adc_t; |
||
81 | |||
82 | /* The number of messages in the queue. If messages arrive faster than they are
|
||
83 | * handled, old ones are thrown out */
|
||
84 | 572adceb | Alex Zirbel | #define QUEUE_SIZE 10 |
85 | a826ac0f | Dev Gurjar | |
86 | /** @brief Initialize the analog module and driver. **/
|
||
87 | int main(int argc, char **argv); |
||
88 | |||
89 | /** @brief given a port, returns the analog reading at that port **/
|
||
90 | unsigned int get_sensor_data(int port); |
||
91 | |||
92 | /** @brief Responds to service to query analog input. **/
|
||
93 | bool analog_query(analog::query_analog::Request &req,
|
||
94 | analog::query_analog::Response &res); |
||
95 | #endif |