?lang_form? ?lang_select? ?lang_submit? ?lang_endform?
{HEADER END}
{BLAME START}

library

?curdirlinks? -

Blame information for rev 6

Line No. Rev Author Line
1 6 kaklik //*****************************************************************************
2 // File Name : ds2450.c
3 // Title : Dallas 1-Wire DS2450 A2D Sensor Library
4 // Revision : 5
5 // Notes :
6 // Target MCU : Atmel AVR series
7 // Editor Tabs : 4
8 //
9 // Revision History:
10 // When Who Rev Description of change
11 // ----------- ----------- ------- -----------------------
12 // 07-Aug-2006 pwilliams 6 Fixed Error in strupr usage causing stack corruption
13 // 01-Oct-2003 rwatson 5 Fixed result error with MSB
14 // 30-Sep-2003 rwatson 4 CreatedDigitalOut
15 // 30-Sep-2003 rwatson 3 Created SetupAlll, StartAll, ResultAll, StartAndResultAll
16 // 29-Sep-2003 rwatson 2 Created Setup, Start, Result, StartAndResult
17 // 29-Sep-2003 rwatson 1 Created the program structure
18 //*****************************************************************************
19  
20 #ifndef ds2450_h
21 #define ds2450_h
22  
23 //----- Include Files ---------------------------------------------------------
24 #include "global.h"
25  
26 //----- Defines ---------------------------------------------------------------
27 #define ds2450_rev 6
28  
29 // the two voltage ranges
30 #define DS2450_RANGE_2V 0x00 // 0-2.55V
31 #define DS2450_RANGE_5V 0x01 // 0-5.10V
32  
33 // the family code
34 #define DS2450_FAMILY 0x20
35  
36 // the starting addresses
37 // of the pages in RAM
38 #define DS2450_DATA_PAGE 0x00
39 #define DS2450_SETUP_PAGE 0x08
40 #define DS2450_ALARM_PAGE 0x10
41  
42 #define DS2450_VCC_FLAG 0x40
43 #define DS2450_VCC_ADDR 0x1C
44  
45 // maximum allowable resolution
46 #define DS2450_RES_MAX 16
47  
48 // function commands
49 #define DS2450_READ_MEMORY 0xAA
50 #define DS2450_WRITE_MEMORY 0x55
51 #define DS2450_CONVERT 0x3C
52 #define DS2450_CONVERT_ALL4_MASK 0x0F
53 #define DS2450_CLEAR_ALL4_MASK 0x55
54  
55 //----- Typedefs --------------------------------------------------------------
56  
57 // enumerated constant for configuring
58 // and controlling an A2D channel as a digital output
59 typedef enum {DIGOUT_LOW=0x80, DIGOUT_OC=0xC0, DIGOUT_DISABLE=0x00} dallas_a2d_out_T;
60  
61 //----- Functions ---------------------------------------------------------------
62  
63 // ds2450Init()
64 // initializes the dallas 1-wire bus
65 void ds2450Init(void);
66  
67 //----- Single Channel Functions ----------------------------------------------
68 // The following 4 functions are used for controlling a single channel on the
69 // a2d converter. If you are only using 1 channel, then these functions are
70 // faster. If you are using 2 or more channel, it is faster to use the All
71 // Channel Functions. This is because to convert all the channel only requires
72 // one command to the device, and then a read of the all the channel. To read
73 // two channel individually requires two commands to the device, and two reads.
74 // Therefore using the All Channel Functions for even just 2 channels is faster
75 // and more effificient.
76  
77 // ds2450Setup()
78 // Sets up the given device, for the given channel [A-D],
79 // the given resolution [1-16] and the given range 0-2.55 or 0-5.10
80 // Returns either the corresponding error or DALLAS_NO_ERROR
81 u08 ds2450Setup(dallas_rom_id_T* rom_id, u08 channel, u08 resolution, u08 range);
82  
83 // ds2450Start()
84 // Starts the a2d conversion for the given device and the given channel [A-D]
85 // Returns either the corresponding error or DALLAS_NO_ERROR
86 u08 ds2450Start(dallas_rom_id_T* rom_id, u08 channel);
87  
88 // ds2450Result()
89 // Gets the result from the a2d conversion
90 // for the given device and the given channel [A-D]
91 // Returns either the corresponding error or DALLAS_NO_ERROR
92 u08 ds2450Result(dallas_rom_id_T* rom_id, u08 channel, u16* result);
93  
94 // ds2450StartAndResult()
95 // Starts the conversion of the given device and the given channel [A-D]
96 // Stores the result in the variable result
97 // Returns either the corresponding error or DALLAS_NO_ERROR
98 u08 ds2450StartAndResult(dallas_rom_id_T* rom_id, u08 channel, u16 *result);
99  
100 //----- All Channel Functions -------------------------------------------------
101 // The following 4 commands are used to access data from all 4 channels on the
102 // a2d converter. These commands should be used if you are using more than one
103 // channel on the device. See the Single Channel Functions description for
104 // more information
105  
106 // ds2450SetupAll()
107 // Sets up the given device for all channels for the given resultion
108 // and the given range [0-2.55 or 0-5.10]
109 // Returns either the corresponding error or DALLAS_NO_ERROR
110 u08 ds2450SetupAll(dallas_rom_id_T* rom_id, u08 resolution, u08 range);
111  
112 // ds2450StartAll()
113 // Starts the conversion for all 4 channels on the given a2d converter
114 // Returns either the corresponding error or DALLAS_NO_ERROR
115 u08 ds2450StartAll(dallas_rom_id_T* rom_id);
116  
117 // ds2450ResultAll
118 // Gets the results from the given device
119 // and stores the result in the given array
120 // Returns either the corresponding error or DALLAS_NO_ERROR
121 u08 ds2450ResultAll(dallas_rom_id_T* rom_id, u16 result[4]);
122  
123 // ds2450StartAndResultAll()
124 // 1-Step command to start the conversion for the given device,
125 // and store the results in the given array
126 // Returns either the corresponding error or DALLAS_NO_ERROR
127 u08 ds2450StartAndResultAll(dallas_rom_id_T* rom_id, u16 result[4]);
128  
129 // ds2450Print()
130 // Does a formatted print on the given result for the given range
131 void ds2450Print(u16 result, u08 range);
132  
133 //----- Digital Out Functions -------------------------------------------------
134 // ds2450DigitalOut
135 // Use the given channel of the given device as a digital out
136 // Returns either the corresponding error or DALLAS_NO_ERROR
137 u08 ds2450DigitalOut(dallas_rom_id_T* rom_id, u08 channel, dallas_a2d_out_T state);
138  
139 #endif
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3