CuVoodoo STM32F1 firmware template
onewire_master.h
Go to the documentation of this file.
1 /* This program is free software: you can redistribute it and/or modify
2  * it under the terms of the GNU General Public License as published by
3  * the Free Software Foundation, either version 3 of the License, or
4  * (at your option) any later version.
5  *
6  * This program is distributed in the hope that it will be useful,
7  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  * GNU General Public License for more details.
10  *
11  * You should have received a copy of the GNU General Public License
12  * along with this program. If not, see <http://www.gnu.org/licenses/>.
13  *
14  */
22 #pragma once
23 
28 #define ONEWIRE_MASTER_PORT C
29 #define ONEWIRE_MASTER_PIN 9
34 void onewire_master_setup(void);
35 
37 void onewire_master_release(void);
41 bool onewire_master_reset(void);
48 uint8_t onewire_master_crc(uint8_t* data, uint32_t length);
53 uint64_t onewire_master_rom_read(void);
62 bool onewire_master_rom_search(uint64_t* code, bool alarm);
67 bool onewire_master_rom_skip(void);
73 bool onewire_master_rom_match(uint64_t code);
79 bool onewire_master_read_byte(uint8_t* data);
85 bool onewire_master_write_byte(uint8_t data);
93 bool onewire_master_function_read(uint8_t function, uint8_t* data, uint32_t bits);
101 bool onewire_master_function_write(uint8_t function, uint8_t* data, uint32_t bits);
102 
106  uint8_t code;
107  const char* device;
108 };
109 
119  {
120  .code = 0x01,
121  .device = "DS1990R/DS2401/DS2411/DS2490A",
122  },
123  {
124  .code = 0x02,
125  .device = "DS1991/DS1425",
126  },
127  {
128  .code = 0x04,
129  .device = "DS1994/DS2404",
130  },
131  {
132  .code = 0x05,
133  .device = "DS2405",
134  },
135  {
136  .code = 0x06,
137  .device = "DS1993",
138  },
139  {
140  .code = 0x08,
141  .device = "DS1992",
142  },
143  {
144  .code = 0x09,
145  .device = "DS1982/DS2502/DS2703/DS2704",
146  },
147  {
148  .code = 0x0a,
149  .device = "DS1995",
150  },
151  {
152  .code = 0x0b,
153  .device = "DS1985/DS2505",
154  },
155  {
156  .code = 0x0c,
157  .device = "DS1996",
158  },
159  {
160  .code = 0x0f,
161  .device = "DS1986/DS2506",
162  },
163  {
164  .code = 0x10,
165  .device = "DS1920/DS18S20",
166  },
167  {
168  .code = 0x12,
169  .device = "DS2406/DS2407",
170  },
171  {
172  .code = 0x14,
173  .device = "DS1971/DS2430A",
174  },
175  {
176  .code = 0x16,
177  .device = "DS1954/DS1957",
178  },
179  {
180  .code = 0x18,
181  .device = "DS1963S/DS1962",
182  },
183  {
184  .code = 0x1a,
185  .device = "DS1963L",
186  },
187  {
188  .code = 0x1b,
189  .device = "DS2436",
190  },
191  {
192  .code = 0x1c,
193  .device = "DS28E04-100",
194  },
195  {
196  .code = 0x1d,
197  .device = "DS2423",
198  },
199  {
200  .code = 0x1e,
201  .device = "DS2437",
202  },
203  {
204  .code = 0x1f,
205  .device = "DS2409",
206  },
207  {
208  .code = 0x20,
209  .device = "DS2450",
210  },
211  {
212  .code = 0x21,
213  .device = "DS1921",
214  },
215  {
216  .code = 0x22,
217  .device = "DS1922",
218  },
219  {
220  .code = 0x23,
221  .device = "DS1973/DS2433",
222  },
223  {
224  .code = 0x24,
225  .device = "DS1904/DS2415",
226  },
227  {
228  .code = 0x26,
229  .device = "DS2438",
230  },
231  {
232  .code = 0x27,
233  .device = "DS2417",
234  },
235  {
236  .code = 0x28,
237  .device = "DS18B20",
238  },
239  {
240  .code = 0x29,
241  .device = "DS2408",
242  },
243  {
244  .code = 0x2c,
245  .device = "DS2890",
246  },
247  {
248  .code = 0x2d,
249  .device = "DS1972/DS2431",
250  },
251  {
252  .code = 0x2e,
253  .device = "DS2770",
254  },
255  {
256  .code = 0x2f,
257  .device = "DS28E01-100",
258  },
259  {
260  .code = 0x30,
261  .device = "DS2760/DS2761/DS2762",
262  },
263  {
264  .code = 0x31,
265  .device = "DS2720",
266  },
267  {
268  .code = 0x32,
269  .device = "DS2780",
270  },
271  {
272  .code = 0x33,
273  .device = "DS1961S/DS2432",
274  },
275  {
276  .code = 0x34,
277  .device = "DS2703",
278  },
279  {
280  .code = 0x35,
281  .device = "DS2755",
282  },
283  {
284  .code = 0x36,
285  .device = "DS2740",
286  },
287  {
288  .code = 0x37,
289  .device = "DS1977",
290  },
291  {
292  .code = 0x3a,
293  .device = "DS2413",
294  },
295  {
296  .code = 0x3b,
297  .device = "DS1825/MAX31826/MAX31850",
298  },
299  {
300  .code = 0x3d,
301  .device = "DS2781",
302  },
303  {
304  .code = 0x41,
305  .device = "DS1922/DS1923/DS2422",
306  },
307  {
308  .code = 0x42,
309  .device = "DS28EA00",
310  },
311  {
312  .code = 0x43,
313  .device = "DS28EC20",
314  },
315  {
316  .code = 0x44,
317  .device = "DS28E10",
318  },
319  {
320  .code = 0x51,
321  .device = "DS2751",
322  },
323  {
324  .code = 0x7e,
325  .device = "EDS00xx",
326  },
327  {
328  .code = 0x81,
329  .device = "DS1420/DS2490R/DS2490B",
330  },
331  {
332  .code = 0x82,
333  .device = "DS1425",
334  },
335  {
336  .code = 0x84,
337  .device = "DS2404S",
338  },
339  {
340  .code = 0x89,
341  .device = "DS1982U/DS2502",
342  },
343  {
344  .code = 0x8b,
345  .device = "DS1985U/DS2505",
346  },
347  {
348  .code = 0x8f,
349  .device = "DS1986U/DS2506",
350  },
351  {
352  .code = 0xa0,
353  .device = "mRS001",
354  },
355  {
356  .code = 0xa1,
357  .device = "mVM001",
358  },
359  {
360  .code = 0xa2,
361  .device = "mCM001",
362  },
363  {
364  .code = 0xa6,
365  .device = "mTS017",
366  },
367  {
368  .code = 0xb1,
369  .device = "mTC001",
370  },
371  {
372  .code = 0xb2,
373  .device = "mAM001",
374  },
375  {
376  .code = 0xb3,
377  .device = "DS2432/mTC002",
378  },
379  {
380  .code = 0xfc,
381  .device = "BAE0910/BAE0911",
382  },
383  {
384  .code = 0xff,
385  .device = "Swart LCD",
386  }
387 };
bool onewire_master_write_byte(uint8_t data)
write data byte
uint64_t onewire_master_rom_read(void)
send READ ROM command and read ROM code response
bool onewire_master_reset(void)
send reset pulse
static const struct onewire_family_code_t onewire_family_codes[]
list of possible devices corresponding to the family code sources:
bool onewire_master_rom_search(uint64_t *code, bool alarm)
send SEARCH ROM command
bool onewire_master_function_read(uint8_t function, uint8_t *data, uint32_t bits)
issue function and read data
bool onewire_master_read_byte(uint8_t *data)
read data byte
bool onewire_master_rom_skip(void)
send SKIP ROM command (all slaves on the bus will be selected)
void onewire_master_release(void)
release 1-wire peripheral
const char * device
device name(s)
device corresponding to a family code
uint8_t onewire_master_crc(uint8_t *data, uint32_t length)
compute CRC for 1-Wire
bool onewire_master_rom_match(uint64_t code)
send MATCH ROM command to select a specific slave
uint8_t code
ROM ID code.
bool onewire_master_function_write(uint8_t function, uint8_t *data, uint32_t bits)
issue function and write data