-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathOWIPolled.h
168 lines (140 loc) · 6.27 KB
/
OWIPolled.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// This file has been prepared for Doxygen automatic documentation generation.
/*! \file ********************************************************************
*
* Atmel Corporation
*
* \li File: OWIPolled.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: Defines used in the polled 1-Wire(R) driver.
*
* $Revision: 1.1.1.1 $
* $Date: 2010-01-07 16:39:25 $
****************************************************************************/
#ifndef _OWI_POLLED_H_
#define _OWI_POLLED_H_
#include "OWIdefs.h"
#include "OWIDeviceSpecific.h"
/*****************************************************************************
User defines
*****************************************************************************/
// Uncomment one of the two following lines to choose between
// software only and UART driver.
#define OWI_SOFTWARE_DRIVER
//#define OWI_UART_DRIVER
/*****************************************************************************
The following defines only has an effect on the software only driver.
*****************************************************************************/
/*! \brief CPU clock frequency.
*
* This define is used to calculate delays when the software only driver
* is used. The CPU frequency must be at least 2.170 MHz to be able to
* generate the shortest delays.
*/
#define CPU_FREQUENCY 8.000
/*! \brief Use internal pull-up resistor on 1-Wire buses.
*
* If this symbol is defined, the internal pull-up resister on the GPIO pins
* of the AVR will be used to generate the necessary pull-up on the bus. If
* an external pull-up resistor is used, uncomment this define.
*/
#define OWI_USE_INTERNAL_PULLUP
// Port configuration registers for 1-Wire buses.
// Make sure that all three registers belong to the same port.
#define OWI_PORT PORTC //!< 1-Wire PORT Data register.
#define OWI_PIN PINC //!< 1-Wire Input pin register.
#define OWI_DDR DDRC //!< 1-Wire Data direction register.
/*****************************************************************************
The following defines only has an effect on the UART driver.
*****************************************************************************/
/*! Use U(S)ART double speed
*
* Set this define to '1' to enable U(S)ART double speed. More information
* can be found in the data sheet of the AVR.
*
* \note The UART Baud Rate Register settings are also affected by this
* setting.
*/
#define OWI_UART_2X 1
/*! UART Baud Rate register setting that results in 115200 Baud
*
* This define should be set to the UBRR value that will generate
* a Baud rate of 115200. See data sheet for more information and
* examples of Baud rate settings.
*/
#define OWI_UBRR_115200 8
/*! UART Baud Rate register setting that results in 9600 Baud
*
* This define should be set to the UBRR value that will generate
* a Baud rate of 9600. See data sheet for more information and
* examples of Baud rate settings.
*/
#define OWI_UBRR_9600 103
/*****************************************************************************
Other defines
*****************************************************************************/
// Pin bitmasks.
#define OWI_PIN_0 0x01
#define OWI_PIN_1 0x02
#define OWI_PIN_2 0x04
#define OWI_PIN_3 0x08
#define OWI_PIN_4 0x10
#define OWI_PIN_5 0x20
#define OWI_PIN_6 0x40
#define OWI_PIN_7 0x80
/*****************************************************************************
Timing parameters
*****************************************************************************/
#define OWI_DELAY_OFFSET_CYCLES 13 //!< Timing delay when pulling bus low and releasing bus.
/*
// Bit timing delays in clock cycles (= us*clock freq in MHz).
#define OWI_DELAY_A_STD_MODE ((6 * CPU_FREQUENCY) - OWI_DELAY_OFFSET_CYCLES)
#define OWI_DELAY_B_STD_MODE ((64 * CPU_FREQUENCY) - OWI_DELAY_OFFSET_CYCLES)
#define OWI_DELAY_C_STD_MODE ((60 * CPU_FREQUENCY) - OWI_DELAY_OFFSET_CYCLES)
#define OWI_DELAY_D_STD_MODE ((10 * CPU_FREQUENCY) - OWI_DELAY_OFFSET_CYCLES)
#define OWI_DELAY_E_STD_MODE ((9 * CPU_FREQUENCY) - OWI_DELAY_OFFSET_CYCLES)
#define OWI_DELAY_F_STD_MODE ((55 * CPU_FREQUENCY) - OWI_DELAY_OFFSET_CYCLES)
//#define OWI_DELAY_G_STD_MODE ((0 * CPU_FREQUENCY) - OWI_DELAY_OFFSET_CYCLES)
#define OWI_DELAY_H_STD_MODE ((480 * CPU_FREQUENCY) - OWI_DELAY_OFFSET_CYCLES)
#define OWI_DELAY_I_STD_MODE ((70 * CPU_FREQUENCY) - OWI_DELAY_OFFSET_CYCLES)
#define OWI_DELAY_J_STD_MODE ((410 * CPU_FREQUENCY) - OWI_DELAY_OFFSET_CYCLES)
*/
#define OWI_DELAY_A_STD_MODE (2)
#define OWI_DELAY_B_STD_MODE (80)
#define OWI_DELAY_C_STD_MODE (70)
#define OWI_DELAY_D_STD_MODE (12)
#define OWI_DELAY_E_STD_MODE (10)
#define OWI_DELAY_F_STD_MODE (50)
//#define OWI_DELAY_G_STD_MODE (0)
#define OWI_DELAY_H_STD_MODE (480)
#define OWI_DELAY_I_STD_MODE (20)
#define OWI_DELAY_J_STD_MODE (410)
/*
#define OWI_DELAY_A_STD_MODE (1) //void_delay_us(double 6) con include <util/delay.h>5D
#define OWI_DELAY_B_STD_MODE (21)
#define OWI_DELAY_C_STD_MODE (70)
#define OWI_DELAY_D_STD_MODE (12)
#define OWI_DELAY_E_STD_MODE (20)
#define OWI_DELAY_F_STD_MODE (35)
#define OWI_DELAY_I_STD_MODE (70)
*/
/*
#define OWI_DELAY_A_STD_MODE (6) //void_delay_us(double 6) con include <util/delay.h>
#define OWI_DELAY_B_STD_MODE (64)
#define OWI_DELAY_C_STD_MODE (60)
#define OWI_DELAY_D_STD_MODE (10)
#define OWI_DELAY_E_STD_MODE (9)
#define OWI_DELAY_F_STD_MODE (55)
//#define OWI_DELAY_G_STD_MODE (0)
#define OWI_DELAY_H_STD_MODE (480)
#define OWI_DELAY_I_STD_MODE (70)
#define OWI_DELAY_J_STD_MODE (410)
*/
/*!!!!WARNING: due to a change in the cpu frequency needed by baud settings, time longer then 150 us are not reachable in a single delay loop*/
#endif