root / scout / analog / src / analog.h @ c492be62
History | View | Annotate | Download (2.79 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 | //#include "analog/set_motors.h"
|
||
42 | |||
43 | /** @brief Analog port 0 **/
|
||
44 | #define AN0 0x00 |
||
45 | /** @brief Analog port 1 **/
|
||
46 | #define AN1 0x01 |
||
47 | /** @brief Analog port 2 **/
|
||
48 | #define AN2 0x02 |
||
49 | /** @brief Analog port 3 **/
|
||
50 | #define AN3 0x03 |
||
51 | /** @brief Analog port 4 **/
|
||
52 | #define AN4 0x04 |
||
53 | /** @brief Analog port 5 **/
|
||
54 | #define AN5 0x05 |
||
55 | /** @brief Analog port 6 **/
|
||
56 | #define AN6 0x06 |
||
57 | /** @brief Analog port 7 **/
|
||
58 | #define AN7 0x07 |
||
59 | /** @brief Analog port 8 **/
|
||
60 | #define AN8 0x08 |
||
61 | /** @brief Analog port 9 **/
|
||
62 | #define AN9 0x09 |
||
63 | /** @brief Analog port 10 **/
|
||
64 | #define AN10 0x0A |
||
65 | /** @brief Analog port 11 **/
|
||
66 | #define AN11 0x0B |
||
67 | /** @brief Analog port 12 **/
|
||
68 | #define AN12 0x0C |
||
69 | /** @brief Analog port 13 **/
|
||
70 | #define AN13 0x0D |
||
71 | /** @brief Analog port 14 **/
|
||
72 | #define AN14 0x0E |
||
73 | /** @brief Analog port 15 **/
|
||
74 | 8e7baefc | Dev Gurjar | #define AN15 0x0F |
75 | a826ac0f | Dev Gurjar | |
76 | /** @brief Struct to hold the value of a particular analog port **/
|
||
77 | typedef struct { |
||
78 | 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 | #define QUEUE_SIZE 4 |
||
85 | |||
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 |