-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.h
executable file
·211 lines (144 loc) · 4.3 KB
/
config.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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/* config.h
*
* All the user-editable variables needed by the different libraries.
* Specific instructions can be found lower.
*
* Copyright 2015 - 2017 (C) Taz8du29
* Refer to LICENSE.MD for more infos about copyright
*/
#ifndef _MYUTILS_CONFIG_H_
#define _MYUTILS_CONFIG_H_
/*******************************
* INTERRUPTS
*******************************/
/* If you are using interrupts, it is recommended to disable them during
* operations on 16 bits registers. Just uncomment the "pwm_interrupts" line
* and every function using 16 bits registers will disable interrupts long
* enough to operate.
*/
// #define using_interrupts 1
/*******************************
* SHIFTING
*******************************/
// All pins must be on the same port
#define shift_DIR DDRD
#define shift_PORT PORTD
#define shift_PIN PIND
// Pin Name Pin HC595 HC165
#define shift_DATA PD3 // SER Qh
#define shift_CLK PD4 // SRCLK CLK
#define shift_LD PD5 // RCLK SH/_LD
#define shift_IOE PD6 // _OE CLK INH
/*******************************
* FUSERESC
*******************************/
/* IT'S RECOMMENDED TO NOT EDIT THIS PINS AND PORTS CONFIG. */
// Target's enable pin
#define fresc_OE PD0
// Clock pin (XTAL1)
#define fresc_CLK PD1
// Prog_enable = [WR, BS1, XA0, XA1];
#define fresc_WR PD2 // Write pulse
#define fresc_BS1 PD3 // Byte select 1 OR Page Load
#define fresc_XA0 PD4 // Xtal Action bit 0
#define fresc_XA1 PD5 // Xtal Action bit 1 OR Byte select 2
// Input pin used to read target's status
#define fresc_RDY PD6
// Power control of the target chip
#define fresc_POW PA0 // 5Vcc
#define fresc_RES PA1 // 12Vcc aka Reset
/*******************************
* HARDWARE UART
*******************************/
// Pin configuration
#define uart_hard_DIR DDRD
#define uart_hard_PORT PORTD
#define uart_hard_PIN PD6
// Frame formats (Uncomment wanted one)
#define uart_hard_BITS_PARITY (0<<UPM0) // No parity bit
// #define uart_hard_BITS_PARITY (2<<UPM0) // Even parity
// #define uart_hard_BITS_PARITY (3<<UPM0) // Odd parity
#define uart_hard_BITS_STOP (0<<USBS) // One stop bit
// #define uart_hard_BITS_STOP (1<<USBS) // Two stop bits
#define uart_hard_BITS_DATA 8 // 5,6,7,8 or 9 bits
/*******************************
* SOFTWARE UART
*******************************/
// Pin configuration
#define uart_soft_DIR DDRD
#define uart_soft_PORT PORTD
#define uart_soft_PIN PIND
#define uart_soft_RX_BIT PD5
#define uart_soft_TX_BIT PD6
/*******************************
* I²C
*******************************/
/* Pin configuration
*
* Warning : You must change these to match your hardware.
*
* This pin configuration is for an attiny 2313a.
* I had to define new names for values because I/O definition file ones have
* ambiguous names.
*/
// I²C
#define i2c_DIR DDRB
#define i2c_PORT PORTB
#define i2c_PIN PINB
// SDA (data)
#define i2c_SDA_BIT PB5
// SCL (clock)
#define i2c_SCL_BIT PB7
// transfer modes
#define i2c_WRITE 0
#define i2c_READ 1
// Device's address, in slave mode (change it if you desire)
#define i2c_address 0x69
/*******************************
* SPI
*******************************/
/* Pin configuration
*
* Warning : You must change these to match your hardware.
*
* This pin configuration is for an attiny 2313a.
* I had to define new names for values because I/O definition file ones have
* ambiguous names.
*/
// SPI ports
#define spi_DDR DDRB
#define spi_PORT PORTB
#define spi_PIN PINB
// MOSI (master out, slave in)
#define spi_MOSI_BIT PB5
// MISO (master in, slave out)
#define spi_MISO_BIT PB6
// SCK (clock)
#define spi_SCK_BIT PB7
/*******************************
* HD44780
*******************************/
// LCD mode : 4 or 8 bits
#define lcd_mode 4
// Number of lines on display : 1, 2 or 4
#define lcd_lines 2
// Data ports (bits [0-3] or [0-7] used)
#define lcd_DATA_DIR DDRB
#define lcd_DATA_PORT PORTB
#define lcd_DATA_PIN PINB
// Command ports
#define lcd_CMD_DIR DDRD
#define lcd_CMD_PORT PORTD
// Command bits
#define lcd_EN PD5
#define lcd_RS PD4
#define lcd_RW PD3
/*******************************
* SSD1306
*******************************/
// I²C address used by the device (default : 0x7A or 0x7B)
#define glcd_address 0x7B
// Screen size (in pixels)
#define glcd_Vsize 64
#define glcd_Hsize 128
#endif /* !_MYUTILS_CONFIG_H_ */