-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathOWIBitFunctions.h
95 lines (79 loc) · 2.62 KB
/
OWIBitFunctions.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// This file has been prepared for Doxygen automatic documentation generation.
/*! \file ********************************************************************
*
* Atmel Corporation
*
* \li File: OWIBitFunctions.h
* \li Compiler: IAR EWAAVR 3.20a
* \li Support mail: [email protected]
*
* \li Supported devices: All AVRs.
*
* \li Application Note: AVR318 - Dallas 1-Wire(R) master.
*
*
* \li Description: Header file for OWIBitFunctions.c
*
* $Revision: 1.4 $
* $Date: 2011-11-04 11:56:09 $
****************************************************************************/
#ifndef _OWI_BIT_FUNCTIONS_H_
#define _OWI_BIT_FUNCTIONS_H_
#include "OWIdefs.h"
#include "OWIPolled.h"
#ifdef OWI_SOFTWARE_DRIVER
uint8_t OWI_Init(unsigned char pins);
void OWI_WriteBit1(unsigned char pins);
void OWI_WriteBit0(unsigned char pins);
void OWI_WriteBit0ShortRelease(unsigned char pins);
unsigned char OWI_ReadBit(unsigned char pins);
unsigned char OWI_DetectPresence(unsigned char pins);
/*void OWI_ResetPulse(unsigned char pins);*/
#endif
#ifdef OWI_UART_DRIVER
unsigned char OWI_TouchBit(unsigned char outValue);
void OWI_Init();
#define OWI_Init(arg) OWI_Init()
void OWI_WriteBit1();
#define OWI_WriteBit1(arg) OWI_WriteBit1()
void OWI_WriteBit0();
#define OWI_WriteBit0(arg) OWI_WriteBit0()
unsigned char OWI_ReadBit();
#define OWI_ReadBit(arg) OWI_ReadBit()
unsigned char OWI_DetectPresence();
#define OWI_DetectPresence(arg) OWI_DetectPresence()
#endif // OWI_UART_DRIVER
/****************************************************************************
Macros
****************************************************************************/
/*! \brief Pull 1-Wire bus low.
*
* This macro sets the direction of the 1-Wire pin(s) to output and
* pull the line(s) low.
*
* \param bitMask A bitmask of the buses to pull low.
*/
#define OWI_PULL_BUS_LOW(bitMask) \
OWI_DDR |= bitMask; \
OWI_PORT &= ~bitMask;
/*! \def OWI_RELEASE_BUS(bitMask)
*
* \brief Release the bus.
*
* This macro releases the bus and enables the internal pull-up if
* it is used.
*
* \param bitMask A bitmask of the buses to release.
*/
#ifdef OWI_USE_INTERNAL_PULLUP
// Set 1-Wire pin(s) to input and enable internal pull-up resistor.
#define OWI_RELEASE_BUS(bitMask) \
OWI_DDR &= ~bitMask; \
OWI_PORT |= bitMask;
#else
// Set 1-Wire pin(s) to input mode. No internal pull-up enabled.
#define OWI_RELEASE_BUS(bitMask) \
OWI_DDR &= ~bitMask; \
OWI_PORT &= ~bitMask;
#endif
#endif