-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathportmacros.h
93 lines (72 loc) · 2.68 KB
/
portmacros.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
/*
portmacros.h - driver code for NXP LPC176x ARM processors
Part of grblHAL
Copyright (c) 2018-2022 Terje Io
Grbl 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.
Grbl 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 Grbl. If not, see <http://www.gnu.org/licenses/>.
*/
#include "chip.h"
#define DIGITAL_IN(gpio, bit) (!!(gpio->PIN & bit))
#define DIGITAL_OUT(gpio, bit, on) { if(on) gpio->SET = bit; else gpio->CLR = bit; }
// Added missing definition for GPIO0
#define LPC_GPIO0 ((LPC_GPIO_T *) LPC_GPIO0_BASE)
#define port(p) portI(p)
#define portI(p) LPC_GPIO ## p
#define portINTER(p) portQR(p)
#define portQR(p) LPC_GPIOINT->IO ## p.ENR
#define portINTEF(p) portQF(p)
#define portQF(p) LPC_GPIOINT->IO ## p.ENF
#define portINTSR(p) portQSR(p)
#define portQSR(p) LPC_GPIOINT->IO ## p.STATR
#define portINTSF(p) portQSF(p)
#define portQSF(p) LPC_GPIOINT->IO ## p.STATF
#define portINTCLR(p) portC(p)
#define portC(p) LPC_GPIOINT->IO ## p.CLR
#define portRDI(p) portR(p * 2)
#define portR(p) PINMODE ## p
#define P0Int (1<<0)
#define P2Int (1<<2)
#define GPIO_IRQHandler EINT3_IRQHandler
#define timer(p) timerN(p)
#define timerN(p) LPC_TIMER ## p
#define timerINT0(p) timerI0(p)
#define timerI0(p) TIMER ## p ## _IRQn
#define timerINTN(p) timerIN(p)
#define timerIN(p) T ## p ## _N_IRQn
#define timerISR(p) timerS(p)
#define timerS(p) TIMER ## p ## _IRQHandler
#define timerPCLK(p) timerCK(p)
#define timerCK(p) SYSCTL_PCLK_TIMER ## p
#define MR0I (1<<0)
#define MR0R (1<<1)
#define MR0S (1<<2)
#define MR1I (1<<3)
#define MR1R (1<<4)
#define MR1S (1<<5)
#define MR0IFG (1<<0)
#define MR1IFG (1<<1)
// Define timer registers
#define STEPPER_TIM 1
#define STEPPER_TIMER timer(STEPPER_TIM)
#define STEPPER_TIMER_INT0 timerINT0(STEPPER_TIM)
#define STEPPER_TIMER_PCLK timerPCLK(STEPPER_TIM)
#define STEPPER_IRQHandler timerISR(STEPPER_TIM)
#define PULSE_TIM 0
#define PULSE_TIMER timer(PULSE_TIM)
#define PULSE_TIMER_INT0 timerINT0(PULSE_TIM)
#define PULSE_TIMER_PCLK timerPCLK(PULSE_TIM)
#define STEPPULSE_IRQHandler timerISR(PULSE_TIM)
#define DEBOUNCE_TIM 2
#define DEBOUNCE_TIMER timer(DEBOUNCE_TIM)
#define DEBOUNCE_TIMER_INT0 timerINT0(DEBOUNCE_TIM)
#define DEBOUNCE_TIMER_PCLK timerPCLK(DEBOUNCE_TIM)
#define DEBOUNCE_IRQHandler timerISR(DEBOUNCE_TIM)
// EOF