µracoli Manual Version foo

- µracoli
- User Guide
- Reference Guide

ow.h
1 /* Copyright (c) 2014 Daniel Thiele, Axel Wachtler
2 All rights reserved.
3
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions
6 are met:
7
8 * Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 * Neither the name of the authors nor the names of its contributors
14 may be used to endorse or promote products derived from this software
15 without specific prior written permission.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 POSSIBILITY OF SUCH DAMAGE. */
28
29 #ifndef OW_H
30 #define OW_H
31
37 /* === includes ============================================================ */
38
39 #include <stdbool.h>
40 #include <avr/io.h>
41
42 /* === macros ============================================================== */
43
44 #define PINHI(pin) pin##_PORT |= (1<<pin)
45 #define PINLO(pin) pin##_PORT &= ~(1<<pin)
46 #define PINOUTP(pin) pin##_DDR |= (1<<pin)
47 #define PININP(pin) pin##_DDR &= ~(1<<pin)
48 #define PINGET(pin) (0 != (pin##_PIN & (1<<pin)))
49
50
51 //#define DBG_SLOT_PIN PINB
52 //#define DBG_SLOT_DDR DDRB
53 //#define DBG_SLOT_PORT PORTB
54 //#define DBG_SLOT (PB7)
55
56 #define OW_ROMCMD_READ (0x33)
57 #define OW_ROMCMD_MATCH (0x55)
58 #define OW_ROMCMD_SEARCH (0xF0)
59 #define OW_ROMCMD_ALARM (0xEC)
60 #define OW_ROMCMD_SKIP (0xCC)
61
62 /* === types =============================================================== */
63
64 typedef uint64_t ow_serial_t;
65
66 /* === prototypes ========================================================== */
67 #ifdef __cplusplus
68 extern "C" {
69 #endif
70
71 void ow_init(void);
73 uint8_t ow_reset(void);
75 void ow_byte_write(uint8_t byte);
77 uint8_t ow_byte_read(void);
79 bool ow_crc_valid(uint8_t * pdata, uint8_t size);
81 bool ow_master_searchrom(ow_serial_t *ser, bool first);
83 void ow_master_matchrom(ow_serial_t ser);
84
85 #ifdef __cplusplus
86 } /* extern "C" */
87 #endif
88
89 #endif /* OW_H */
ow_crc_valid
bool ow_crc_valid(uint8_t *pdata, uint8_t size)
ow_master_searchrom
bool ow_master_searchrom(ow_serial_t *ser, bool first)
ow_reset
uint8_t ow_reset(void)
ow_master_matchrom
void ow_master_matchrom(ow_serial_t ser)
ow_byte_read
uint8_t ow_byte_read(void)
ow_byte_write
void ow_byte_write(uint8_t byte)
ow_init
void ow_init(void)