359 |
kaklik |
1 |
|
|
|
2 |
/****************************************************************************
|
|
|
3 |
Title : C include file for the SRF08 FUNCTIONS library (srf08.h)
|
|
|
4 |
Author: Chris efstathiou hendrix@otenet.gr
|
|
|
5 |
Date: 13/Jul/2002
|
|
|
6 |
Software: AVR-GCC with AVR-AS
|
|
|
7 |
Target: any AVR device
|
|
|
8 |
Comments: This software is FREE.
|
|
|
9 |
|
|
|
10 |
*****************************************************************************/
|
|
|
11 |
|
|
|
12 |
#ifndef SRF08_H
|
|
|
13 |
#define SRF08_H 1
|
|
|
14 |
|
|
|
15 |
/*##############################################################################################*/
|
|
|
16 |
/* START OF CONFIGURATION BLOCK */
|
|
|
17 |
/*##############################################################################################*/
|
|
|
18 |
/* Normally you shouldn't need to change anything */
|
|
|
19 |
|
|
|
20 |
#define SRF08_UNIT_0 0xE0 /* the SRF08 MODULE I2C address */
|
|
|
21 |
#define SRF08_UNIT_1 0xE2 /* the SRF08 MODULE I2C address */
|
|
|
22 |
#define SRF08_UNIT_2 0xE4 /* the SRF08 MODULE I2C address */
|
|
|
23 |
#define SRF08_UNIT_3 0xE6 /* the SRF08 MODULE I2C address */
|
|
|
24 |
#define SRF08_UNIT_4 0xE8 /* the SRF08 MODULE I2C address */
|
|
|
25 |
#define SRF08_UNIT_5 0xEA /* the SRF08 MODULE I2C address */
|
|
|
26 |
#define SRF08_UNIT_6 0xEC /* the SRF08 MODULE I2C address */
|
|
|
27 |
#define SRF08_UNIT_7 0xEE /* the SRF08 MODULE I2C address */
|
|
|
28 |
#define SRF08_UNIT_8 0xF0 /* the SRF08 MODULE I2C address */
|
|
|
29 |
#define SRF08_UNIT_9 0xF2 /* the SRF08 MODULE I2C address */
|
|
|
30 |
#define SRF08_UNIT_10 0xF4 /* the SRF08 MODULE I2C address */
|
|
|
31 |
#define SRF08_UNIT_11 0xF6 /* the SRF08 MODULE I2C address */
|
|
|
32 |
#define SRF08_UNIT_12 0xF8 /* the SRF08 MODULE I2C address */
|
|
|
33 |
#define SRF08_UNIT_13 0xFA /* the SRF08 MODULE I2C address */
|
|
|
34 |
#define SRF08_UNIT_14 0xFC /* the SRF08 MODULE I2C address */
|
|
|
35 |
#define SRF08_UNIT_15 0xFE /* the SRF08 MODULE I2C address */
|
|
|
36 |
|
|
|
37 |
/*##############################################################################################*/
|
|
|
38 |
/* END OF CONFIGURATION BLOCK */
|
|
|
39 |
/*##############################################################################################*/
|
|
|
40 |
|
|
|
41 |
#define SRF08_I2C_BROADCAST_ADDRESS 0X00
|
|
|
42 |
|
|
|
43 |
#define SRF08_MIN_GAIN 0 /* sets gain to 94 */
|
|
|
44 |
#define SRF08_MAX_GAIN 31 /* sets gain to 1025 */
|
|
|
45 |
#define SRF08_MIN_RANGE 0 /* in millimeters */
|
|
|
46 |
#define SRF08_MAX_RANGE 11008 /* in millimeters */
|
|
|
47 |
|
|
|
48 |
#define SRF08_INCHES 0X50
|
|
|
49 |
#define SRF08_CENTIMETERS 0X51
|
|
|
50 |
#define SRF08_MICROSECONDS 0X52
|
|
|
51 |
|
|
|
52 |
/* register positions */
|
|
|
53 |
#define SRF08_COMMAND 0
|
|
|
54 |
#define SRF08_LIGHT 1
|
|
|
55 |
#define SRF08_ECHO_1 2
|
|
|
56 |
#define SRF08_ECHO_2 4
|
|
|
57 |
#define SRF08_ECHO_3 6
|
|
|
58 |
#define SRF08_ECHO_4 8
|
|
|
59 |
#define SRF08_ECHO_5 10
|
|
|
60 |
#define SRF08_ECHO_6 12
|
|
|
61 |
#define SRF08_ECHO_7 14
|
|
|
62 |
#define SRF08_ECHO_8 16
|
|
|
63 |
#define SRF08_ECHO_9 18
|
|
|
64 |
#define SRF08_ECHO_10 20
|
|
|
65 |
#define SRF08_ECHO_11 22
|
|
|
66 |
#define SRF08_ECHO_12 24
|
|
|
67 |
#define SRF08_ECHO_13 26
|
|
|
68 |
#define SRF08_ECHO_14 28
|
|
|
69 |
#define SRF08_ECHO_15 30
|
|
|
70 |
#define SRF08_ECHO_16 32
|
|
|
71 |
#define SRF08_ECHO_17 34
|
|
|
72 |
|
|
|
73 |
/* Function Declaration */
|
|
|
74 |
|
|
|
75 |
extern void srf08_select_unit(unsigned char srf08_address);
|
|
|
76 |
extern void srf08_init(void);
|
|
|
77 |
|
|
|
78 |
extern void srf08_set_gain(unsigned char gain);
|
|
|
79 |
extern void srf08_set_range(unsigned int millimeters);
|
|
|
80 |
|
|
|
81 |
extern unsigned int srf08_ping(unsigned char metric_unit);
|
|
|
82 |
extern unsigned int srf08_read_register(unsigned char srf08_register);
|
|
|
83 |
|
|
|
84 |
extern void srf08_change_i2c_address(unsigned char new_i2c_address);
|
|
|
85 |
|
|
|
86 |
|
|
|
87 |
#endif /* #ifndef SRF08_H */
|
|
|
88 |
/*######################################################################################################*/
|
|
|
89 |
/* T H E E N D */
|
|
|
90 |
/*######################################################################################################*/
|
|
|
91 |
|