forked from norbert-walter/esp32-nmea2000-obp60
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GwHardware.h
232 lines (207 loc) · 5.64 KB
/
GwHardware.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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
/*
This code is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This code 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
unfortunately there is some typo here: M5 uses GROVE for their connections
but we have GROOVE here.
But to maintain compatibility to older build commands we keep the (wrong) wording
*/
#ifdef _NOGWHARDWAREUT
#error "you are not allowed to include GwHardware.h in your user task header"
#endif
#ifndef _GWHARDWARE_H
#define _GWHARDWARE_H
#define GWSERIAL_TYPE_UNI 1
#define GWSERIAL_TYPE_BI 2
#define GWSERIAL_TYPE_RX 3
#define GWSERIAL_TYPE_TX 4
#include <GwConfigItem.h>
#include <HardwareSerial.h>
#include "GwAppInfo.h"
#include "GwUserTasks.h"
#ifdef GW_PINDEFS
#define GWRESOURCE_USE(RES,USER) \
__MSG(#RES " used by " #USER) \
static int _resourceUsed ## RES =1;
#define __USAGE __MSG
#else
#define GWRESOURCE_USE(...)
#define __USAGE(...)
#endif
#ifndef CFG_INIT
#define CFG_INIT(...)
#endif
//general definitions for M5AtomLite
//hint for groove pins:
//according to some schematics the numbering is 1,2,3(VCC),4(GND)
#ifdef PLATFORM_BOARD_M5STACK_ATOM
#define GROOVE_PIN_2 GPIO_NUM_26
#define GROOVE_PIN_1 GPIO_NUM_32
#define GWBUTTON_PIN GPIO_NUM_39
#define GWLED_FASTLED
#define GWLED_TYPE SK6812
//color schema for fastled
#define GWLED_SCHEMA GRB
#define GWLED_PIN GPIO_NUM_27
#define GWBUTTON_ACTIVE LOW
//if GWBUTTON_PULLUPDOWN we enable a pulup/pulldown
#define GWBUTTON_PULLUPDOWN
#define BOARD_LEFT1 GPIO_NUM_22
#define BOARD_LEFT2 GPIO_NUM_19
#define BOARD_LEFT3 GPIO_NUM_23
#define BOARD_LEFT4 GPIO_NUM_33
#define BOARD_RIGHT1 GPIO_NUM_21
#define BOARD_RIGHT2 GPIO_NUM_25
#define USBSerial Serial
#endif
//general definitiones for M5AtomS3
#ifdef PLATFORM_BOARD_M5STACK_ATOMS3
#define GROOVE_PIN_2 GPIO_NUM_2
#define GROOVE_PIN_1 GPIO_NUM_1
#define GWBUTTON_PIN GPIO_NUM_41
#define GWLED_FASTLED
#define GWLED_TYPE WS2812
//color schema for fastled
#define GWLED_SCHEMA GRB
#define GWLED_PIN GPIO_NUM_35
#define GWBUTTON_ACTIVE LOW
//if GWBUTTON_PULLUPDOWN we enable a pulup/pulldown
#define GWBUTTON_PULLUPDOWN
#define BOARD_LEFT1 GPIO_NUM_5
#define BOARD_LEFT2 GPIO_NUM_6
#define BOARD_LEFT3 GPIO_NUM_7
#define BOARD_LEFT4 GPIO_NUM_8
#define BOARD_RIGHT1 GPIO_NUM_39
#define BOARD_RIGHT2 GPIO_NUM_38
#endif
//M5Stick C
#ifdef PLATFORM_BOARD_M5STICK_C
#define GROOVE_PIN_2 GPIO_NUM_32
#define GROOVE_PIN_1 GPIO_NUM_31
#define USBSerial Serial
#endif
//NodeMCU 32 S
#ifdef PLATFORM_BOARD_NODEMCU_32S
#define USBSerial Serial
#endif
#ifdef BOARD_M5ATOM
#define M5_CAN_KIT
//150mA if we power from the bus
#define N2K_LOAD_LEVEL 3
//if using tail485
#define SERIAL_GROOVE_485 1
//brightness 0...255
#define GWLED_BRIGHTNESS 64
#endif
#ifdef BOARD_M5ATOMS3
#define M5_CAN_KIT 1
//150mA if we power from the bus
#define N2K_LOAD_LEVEL 3
//if using tail485
#define SERIAL_GROOVE_485
//brightness 0...255
#define GWLED_BRIGHTNESS 64
#endif
#ifdef BOARD_M5ATOM_CANUNIT
#define M5_CANUNIT 1
#define GWLED_BRIGHTNESS 64
//150mA if we power from the bus
#define N2K_LOAD_LEVEL 3
#endif
#ifdef BOARD_M5ATOMS3_CANUNIT
#define M5_CANUNIT 1
#define GWLED_BRIGHTNESS 64
#endif
#ifdef BOARD_M5ATOM_RS232_CANUNIT
#define M5_CANUNIT 1
#define M5_SERIAL_KIT_232
#define GWLED_BRIGHTNESS 64
#endif
#ifdef BOARD_M5ATOM_RS485_CANUNIT
#define M5_SERIAL_KIT_485
#define M5_CANUNIT 1
#define GWLED_BRIGHTNESS 64
#endif
#ifdef BOARD_M5STICK_CANUNIT
#define M5_CANUNIT 1
#endif
#ifdef BOARD_HOMBERGER
#define ESP32_CAN_TX_PIN GPIO_NUM_5
#define ESP32_CAN_RX_PIN GPIO_NUM_4
//serial input only
#define GWSERIAL_RX GPIO_NUM_16
#define GWSERIAL_TYPE GWSERIAL_TYPE_RX
#define GWBUTTON_PIN GPIO_NUM_0
#define GWBUTTON_ACTIVE LOW
//if GWBUTTON_PULLUPDOWN we enable a pulup/pulldown
#define GWBUTTON_PULLUPDOWN
#endif
#include "GwM5Base.h"
#include "GwM5Grove.h"
#ifdef GWIIC_SDA
#ifdef _GWI_IIC1
#error "you must not define IIC1 on grove and GWIIC_SDA"
#endif
#ifndef GWIIC_SCL
#error "you must both define GWIIC_SDA and GWIIC_SCL"
#endif
#endif
#ifdef GWIIC_SCL
#ifndef GWIIC_SDA
#error "you must both define GWIIC_SDA and GWIIC_SCL"
#endif
#define _GWIIC
#endif
#ifdef GWIIC_SDA2
#ifdef _GWI_IIC2
#error "you must not define IIC2 on grove and GWIIC_SDA2"
#endif
#ifndef GWIIC_SCL2
#error "you must both define GWIIC_SDA2 and GWIIC_SCL2"
#endif
#endif
#ifdef GWIIC_SCL2
#ifndef GWIIC_SDA2
#error "you must both define GWIIC_SDA and GWIIC_SCL2"
#endif
#define _GWIIC
#endif
#ifndef GWLED_TYPE
#ifdef GWLED_CODE
#if GWLED_CODE == 0
#define GWLED_TYPE SK6812
#endif
#if GWLED_CODE == 1
#define GWLED_TYPE WS2812
#endif
#endif
#endif
#ifdef GWLED_TYPE
#define GWLED_FASTLED
#ifndef GWLED_BRIGHTNESS
#define GWLED_BRIGHTNESS 64
#endif
#endif
#ifdef ESP32_CAN_TX_PIN
#ifndef N2K_LOAD_LEVEL
#define N2K_LOAD_LEVEL 3
#endif
#endif
#ifdef GWLED_FASTLED
#ifdef GWLED_BRIGHTNESS
CFG_INIT(ledBrightness,GWSTRINGIFY(GWLED_BRIGHTNESS),NORMAL)
#else
CFG_INIT(ledBrightness,"64",NORMAL)
#endif
#else
CFG_INIT(ledBrightness,"64",HIDDEN)
#endif
#endif