source: pacpussensors/trunk/CanGateway/driver/kvaser/linux/dallas.h@ 103

Last change on this file since 103 was 97, checked in by DHERBOMEZ Gérald, 9 years ago

add include files for kvaser

File size: 5.6 KB
Line 
1/*
2** Copyright 2012 by Kvaser AB, Mölndal, Sweden
3** http://www.kvaser.com
4**
5** This software is dual licensed under the following two licenses:
6** BSD-new and GPLv2. You may use either one. See the included
7** COPYING file for details.
8**
9** License: BSD-new
10** ===============================================================================
11** Redistribution and use in source and binary forms, with or without
12** modification, are permitted provided that the following conditions are met:
13** * Redistributions of source code must retain the above copyright
14** notice, this list of conditions and the following disclaimer.
15** * Redistributions in binary form must reproduce the above copyright
16** notice, this list of conditions and the following disclaimer in the
17** documentation and/or other materials provided with the distribution.
18** * Neither the name of the <organization> nor the
19** names of its contributors may be used to endorse or promote products
20** derived from this software without specific prior written permission.
21**
22** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25** DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
26** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32**
33**
34** License: GPLv2
35** ===============================================================================
36** This program is free software; you can redistribute it and/or
37** modify it under the terms of the GNU General Public License
38** as published by the Free Software Foundation; either version 2
39** of the License, or (at your option) any later version.
40**
41** This program is distributed in the hope that it will be useful,
42** but WITHOUT ANY WARRANTY; without even the implied warranty of
43** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
44** GNU General Public License for more details.
45**
46** You should have received a copy of the GNU General Public License
47** along with this program; if not, write to the Free Software
48** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
49**
50** ---------------------------------------------------------------------------
51**/
52
53#ifndef DALLAS_H
54#define DALLAS_H
55
56/*****************************************************************************/
57
58/* Commands to Dallas-type Memories */
59#define READ_STATUS 0x66
60#define READ_MEMORY 0xf0
61#define WRITE_SCRATCHPAD 0x0f
62#define READ_SCRATCHPAD 0xaa
63#define COPY_SCRATCHPAD 0x55
64#define WRITE_APPLICATION 0x99
65#define READ_APPLICATION 0xc3
66#define COPY_AND_LOCK_APPLICATION 0x5a
67#define READ_ROM 0x33
68#define MATCH_ROM 0x55
69#define SKIP_ROM 0xcc
70#define SEARCH_ROM 0xf0
71
72/* Device Types */
73#define DS1494_CODE 0x04
74#define DS2430_CODE 0x14
75#define DS2431_CODE 0x2d
76
77#define COPY_PASSWORD 0xa5
78#define STATUS_PASSWORD 0x00
79
80#define MAXMEMORY 0x04
81#define MAXHITLEVEL 0x04
82
83#define ONE_MEMORY 0x01
84#define ALL_FOUND 0x02
85#define NOMEMORY 0x03
86
87/*****************************************************************************/
88
89typedef struct s_dallas_context DALLAS_CONTEXT;
90
91struct s_dallas_context {
92 void __iomem *address_out;
93 void __iomem *address_in;
94 unsigned int in_mask;
95 unsigned int out_mask;
96};
97
98typedef enum {
99 dsError_None = 0, // 0
100 dsError_NoDevice, // 1
101 dsError_WrongDevice, // 2
102 dsError_ScratchPadError, // 3
103 dsError_ROMError, // 4
104 dsError_EEPROMError, // 5
105 dsError_BusStuckLow, // 6
106 dsError_NotProgrammed, // 7
107 dsError_ApplicationLocked, // 8
108 dsError_CRCError // 9
109} dsStatus;
110
111/*****************************************************************************/
112
113dsStatus ds_init(DALLAS_CONTEXT *dc);
114void ds_shutdown(DALLAS_CONTEXT *dc);
115
116dsStatus ds_reset(DALLAS_CONTEXT *dc);
117
118int ds_check_for_presence(DALLAS_CONTEXT *dc);
119
120dsStatus ds_read_string(DALLAS_CONTEXT *dc,
121 unsigned int command,
122 unsigned int address,
123 unsigned char *data,
124 int bufsiz);
125
126dsStatus ds_read_memory(unsigned char memory_type,
127 DALLAS_CONTEXT *dc,
128 unsigned int address,
129 unsigned char *data,
130 size_t bufsiz);
131
132dsStatus ds_read_application_area(DALLAS_CONTEXT *dc,
133 unsigned int address,
134 unsigned char *data,
135 int bufsiz);
136
137dsStatus ds_read_rom_64bit(DALLAS_CONTEXT *dc, int port, unsigned char *data);
138
139int ds_verify_area(unsigned char *data, int bufsiz);
140
141
142/*****************************************************************************/
143
144#endif // DALLAS_H
145
Note: See TracBrowser for help on using the repository browser.