-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathhardware.h
96 lines (77 loc) · 2.27 KB
/
hardware.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
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef HARDWARE_H_
#define HARDWARE_H_
#include <avr/io.h>
#include <avr/wdt.h>
#include <avr/power.h>
#include <avr/interrupt.h>
#include <stdint.h>
#include <stdbool.h>
#include "Arduino.h"
#include <SPI.h>
#define FPGA_BUS_PORT PORTB
#define FPGA_BUS_DDR DDRB
#define FPGA_BUS_PIN PINB
#define FPGA_BUS_MASK 0xFF
#define FPGA_BUS_OFFSET 0
#define ADC_BUS_PORT PORTB
#define ADC_BUS_DDR DDRB
#define ADC_BUS_PIN PINB
#define ADC_BUS_MASK 0xF0
#define ADC_BUS_OFFSET 4
#define CCLK_N 3
#define CS_FLASH_N 2
#define INIT_N 30
#define TX_BUSY_N 30
#define DONE_N 5
#define PROGRAM_N 13
#define CCLK_PORT PORTD
#define CCLK_DDR DDRD
#define CCLK_BIT 0
#define CCLK_PIN PIND
#define CS_FLASH_PORT PORTD
#define CS_FLASH_DDR DDRD
#define CS_FLASH_BIT 1
#define CS_FLASH_PIN PIND
#define INIT_PORT PORTD
#define INIT_DDR DDRD
#define INIT_BIT 5
#define INIT_PIN PIND
#define TX_BUSY_PORT PORTD
#define TX_BUSY_DDR DDRD
#define TX_BUSY_BIT 5
#define TX_BUSY_PIN PIND
#define DONE_PORT PORTC
#define DONE_DDR DDRC
#define DONE_BIT 6
#define DONE_PIN PINC
#define PROGRAM_PORT PORTC
#define PROGRAM_DDR DDRC
#define PROGRAM_BIT 7
#define PROGRAM_PIN PINC
#define MISO_PORT PORTB
#define MISO_DDR DDRB
#define MISO_BIT 3
#define MISO_PIN PINB
#define SS_PORT PORTB
#define SS_DDR DDRB
#define SS_BIT 0
#define SS_PIN PINB
#define TOGGLE(p) p ## _PORT = (p ## _PORT ^ (1 << p ## _BIT))
#define SET(p, v) p ## _PORT = (p ## _PORT & ~(1 << p ## _BIT)) | (v << p ## _BIT)
#define VALUE(p) (p ## _PIN & (1 << p ## _BIT))
#define OUT(p) p ## _DDR |= (1 << p ## _BIT)
#define IN(p) p ## _DDR &= ~(1 << p ## _BIT)
#define LINESTATE_DTR 1
#endif /* HARDWARE_H_ */