Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bfb8727

Browse files
authoredFeb 8, 2023
Merge branch 'master' into master
2 parents 425176b + 5b0a7d0 commit bfb8727

File tree

12 files changed

+1096
-92
lines changed

12 files changed

+1096
-92
lines changed
 

‎README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ You can use the [Arduino-ESP32 Online Documentation](https://docs.espressif.com/
3333
* [Getting Started](https://docs.espressif.com/projects/arduino-esp32/en/latest/getting_started.html)
3434
* [Installing (Windows, Linux and macOS)](https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html)
3535
* [Libraries](https://docs.espressif.com/projects/arduino-esp32/en/latest/libraries.html)
36-
* [ESP-IDF as Component](https://docs.espressif.com/projects/arduino-esp32/en/latest/esp-idf_component.html)
36+
* [Arduino as an ESP-IDF component](https://docs.espressif.com/projects/arduino-esp32/en/latest/esp-idf_component.html)
3737
* [FAQ](https://docs.espressif.com/projects/arduino-esp32/en/latest/faq.html)
3838
* [Troubleshooting](https://docs.espressif.com/projects/arduino-esp32/en/latest/troubleshooting.html)
3939

‎boards.txt

Lines changed: 598 additions & 1 deletion
Large diffs are not rendered by default.

‎cores/esp32/WString.cpp

Lines changed: 57 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -176,26 +176,25 @@ void String::invalidate(void) {
176176
init();
177177
}
178178

179-
unsigned char String::reserve(unsigned int size) {
179+
bool String::reserve(unsigned int size) {
180180
if(buffer() && capacity() >= size)
181-
return 1;
181+
return true;
182182
if(changeBuffer(size)) {
183183
if(len() == 0)
184184
wbuffer()[0] = 0;
185-
return 1;
185+
return true;
186186
}
187-
return 0;
187+
return false;
188188
}
189189

190-
unsigned char String::changeBuffer(unsigned int maxStrLen) {
190+
bool String::changeBuffer(unsigned int maxStrLen) {
191191
// Can we use SSO here to avoid allocation?
192192
if (maxStrLen < sizeof(sso.buff) - 1) {
193193
if (isSSO() || !buffer()) {
194194
// Already using SSO, nothing to do
195-
uint16_t oldLen = len();
195+
uint16_t oldLen = len();
196196
setSSO(true);
197197
setLen(oldLen);
198-
return 1;
199198
} else { // if bufptr && !isSSO()
200199
// Using bufptr, need to shrink into sso.buff
201200
char temp[sizeof(sso.buff)];
@@ -205,8 +204,8 @@ unsigned char String::changeBuffer(unsigned int maxStrLen) {
205204
setSSO(true);
206205
memcpy(wbuffer(), temp, maxStrLen);
207206
setLen(oldLen);
208-
return 1;
209207
}
208+
return true;
210209
}
211210
// Fallthrough to normal allocator
212211
size_t newSize = (maxStrLen + 16) & (~0xf);
@@ -230,9 +229,9 @@ unsigned char String::changeBuffer(unsigned int maxStrLen) {
230229
setCapacity(newSize - 1);
231230
setBuffer(newbuffer);
232231
setLen(oldLen); // Needed in case of SSO where len() never existed
233-
return 1;
232+
return true;
234233
}
235-
return 0;
234+
return false;
236235
}
237236

238237
// /*********************************************/
@@ -338,114 +337,117 @@ String & String::operator =(const __FlashStringHelper *pstr) {
338337
// /* concat */
339338
// /*********************************************/
340339

341-
unsigned char String::concat(const String &s) {
340+
bool String::concat(const String &s) {
342341
// Special case if we're concatting ourself (s += s;) since we may end up
343342
// realloc'ing the buffer and moving s.buffer in the method called
344343
if (&s == this) {
345344
unsigned int newlen = 2 * len();
346345
if (!s.buffer())
347-
return 0;
346+
return false;
348347
if (s.len() == 0)
349-
return 1;
348+
return true;
350349
if (!reserve(newlen))
351-
return 0;
350+
return false;
352351
memmove(wbuffer() + len(), buffer(), len());
353352
setLen(newlen);
354353
wbuffer()[len()] = 0;
355-
return 1;
354+
return true;
356355
} else {
357356
return concat(s.buffer(), s.len());
358357
}
359358
}
360359

361-
unsigned char String::concat(const char *cstr, unsigned int length) {
360+
bool String::concat(const char *cstr, unsigned int length) {
362361
unsigned int newlen = len() + length;
363362
if(!cstr)
364-
return 0;
363+
return false;
365364
if(length == 0)
366-
return 1;
365+
return true;
367366
if(!reserve(newlen))
368-
return 0;
367+
return false;
369368
if (cstr >= wbuffer() && cstr < wbuffer() + len())
370369
// compatible with SSO in ram #6155 (case "x += x.c_str()")
371370
memmove(wbuffer() + len(), cstr, length + 1);
372371
else
373372
// compatible with source in flash #6367
374373
memcpy_P(wbuffer() + len(), cstr, length + 1);
375374
setLen(newlen);
376-
return 1;
375+
return true;
377376
}
378377

379-
unsigned char String::concat(const char *cstr) {
378+
bool String::concat(const char *cstr) {
380379
if(!cstr)
381-
return 0;
380+
return false;
382381
return concat(cstr, strlen(cstr));
383382
}
384383

385-
unsigned char String::concat(char c) {
384+
bool String::concat(char c) {
386385
char buf[] = { c, '\0' };
387386
return concat(buf, 1);
388387
}
389388

390-
unsigned char String::concat(unsigned char num) {
389+
bool String::concat(unsigned char num) {
391390
char buf[1 + 3 * sizeof(unsigned char)];
392391
return concat(buf, sprintf(buf, "%d", num));
393392
}
394393

395-
unsigned char String::concat(int num) {
394+
bool String::concat(int num) {
396395
char buf[2 + 3 * sizeof(int)];
397396
return concat(buf, sprintf(buf, "%d", num));
398397
}
399398

400-
unsigned char String::concat(unsigned int num) {
399+
bool String::concat(unsigned int num) {
401400
char buf[1 + 3 * sizeof(unsigned int)];
402401
utoa(num, buf, 10);
403402
return concat(buf, strlen(buf));
404403
}
405404

406-
unsigned char String::concat(long num) {
405+
bool String::concat(long num) {
407406
char buf[2 + 3 * sizeof(long)];
408407
return concat(buf, sprintf(buf, "%ld", num));
409408
}
410409

411-
unsigned char String::concat(unsigned long num) {
410+
bool String::concat(unsigned long num) {
412411
char buf[1 + 3 * sizeof(unsigned long)];
413412
ultoa(num, buf, 10);
414413
return concat(buf, strlen(buf));
415414
}
416415

417-
unsigned char String::concat(float num) {
416+
bool String::concat(float num) {
418417
char buf[20];
419418
char* string = dtostrf(num, 4, 2, buf);
420419
return concat(string, strlen(string));
421420
}
422421

423-
unsigned char String::concat(double num) {
422+
bool String::concat(double num) {
424423
char buf[20];
425424
char* string = dtostrf(num, 4, 2, buf);
426425
return concat(string, strlen(string));
427426
}
428427

429-
unsigned char String::concat(long long num) {
428+
bool String::concat(long long num) {
430429
char buf[2 + 3 * sizeof(long long)];
431430
return concat(buf, sprintf(buf, "%lld", num)); // NOT SURE - NewLib Nano ... does it support %lld?
432431
}
433432

434-
unsigned char String::concat(unsigned long long num) {
433+
bool String::concat(unsigned long long num) {
435434
char buf[1 + 3 * sizeof(unsigned long long)];
436435
ulltoa(num, buf, 10);
437436
return concat(buf, strlen(buf));
438437
}
439438

440-
unsigned char String::concat(const __FlashStringHelper * str) {
441-
if (!str) return 0;
439+
bool String::concat(const __FlashStringHelper * str) {
440+
if (!str)
441+
return false;
442442
int length = strlen_P((PGM_P)str);
443-
if (length == 0) return 1;
443+
if (length == 0)
444+
return true;
444445
unsigned int newlen = len() + length;
445-
if (!reserve(newlen)) return 0;
446+
if (!reserve(newlen))
447+
return false;
446448
memcpy_P(wbuffer() + len(), (PGM_P)str, length + 1);
447449
setLen(newlen);
448-
return 1;
450+
return true;
449451
}
450452

451453
/*********************************************/
@@ -559,48 +561,48 @@ int String::compareTo(const String &s) const {
559561
return strcmp(buffer(), s.buffer());
560562
}
561563

562-
unsigned char String::equals(const String &s2) const {
564+
bool String::equals(const String &s2) const {
563565
return (len() == s2.len() && compareTo(s2) == 0);
564566
}
565567

566-
unsigned char String::equals(const char *cstr) const {
568+
bool String::equals(const char *cstr) const {
567569
if(len() == 0)
568570
return (cstr == NULL || *cstr == 0);
569571
if(cstr == NULL)
570572
return buffer()[0] == 0;
571573
return strcmp(buffer(), cstr) == 0;
572574
}
573575

574-
unsigned char String::operator<(const String &rhs) const {
576+
bool String::operator<(const String &rhs) const {
575577
return compareTo(rhs) < 0;
576578
}
577579

578-
unsigned char String::operator>(const String &rhs) const {
580+
bool String::operator>(const String &rhs) const {
579581
return compareTo(rhs) > 0;
580582
}
581583

582-
unsigned char String::operator<=(const String &rhs) const {
584+
bool String::operator<=(const String &rhs) const {
583585
return compareTo(rhs) <= 0;
584586
}
585587

586-
unsigned char String::operator>=(const String &rhs) const {
588+
bool String::operator>=(const String &rhs) const {
587589
return compareTo(rhs) >= 0;
588590
}
589591

590-
unsigned char String::equalsIgnoreCase(const String &s2) const {
592+
bool String::equalsIgnoreCase(const String &s2) const {
591593
if(this == &s2)
592-
return 1;
594+
return true;
593595
if(len() != s2.len())
594-
return 0;
596+
return false;
595597
if(len() == 0)
596-
return 1;
598+
return true;
597599
const char *p1 = buffer();
598600
const char *p2 = s2.buffer();
599601
while(*p1) {
600602
if(tolower(*p1++) != tolower(*p2++))
601-
return 0;
603+
return false;
602604
}
603-
return 1;
605+
return true;
604606
}
605607

606608
unsigned char String::equalsConstantTime(const String &s2) const {
@@ -630,21 +632,21 @@ unsigned char String::equalsConstantTime(const String &s2) const {
630632
return (equalcond & diffcond); //bitwise AND
631633
}
632634

633-
unsigned char String::startsWith(const String &s2) const {
635+
bool String::startsWith(const String &s2) const {
634636
if(len() < s2.len())
635-
return 0;
637+
return false;
636638
return startsWith(s2, 0);
637639
}
638640

639-
unsigned char String::startsWith(const String &s2, unsigned int offset) const {
641+
bool String::startsWith(const String &s2, unsigned int offset) const {
640642
if(offset > (unsigned)(len() - s2.len()) || !buffer() || !s2.buffer())
641-
return 0;
643+
return false;
642644
return strncmp(&buffer()[offset], s2.buffer(), s2.len()) == 0;
643645
}
644646

645-
unsigned char String::endsWith(const String &s2) const {
647+
bool String::endsWith(const String &s2) const {
646648
if(len() < s2.len() || !buffer() || !s2.buffer())
647-
return 0;
649+
return false;
648650
return strcmp(&buffer()[len() - s2.len()], s2.buffer()) == 0;
649651
}
650652

‎cores/esp32/WString.h

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class String {
8181
// return true on success, false on failure (in which case, the string
8282
// is left unchanged). reserve(0), if successful, will validate an
8383
// invalid string (i.e., "if (s)" will be true afterwards)
84-
unsigned char reserve(unsigned int size);
84+
bool reserve(unsigned int size);
8585
inline unsigned int length(void) const {
8686
if(buffer()) {
8787
return len();
@@ -112,21 +112,21 @@ class String {
112112
// returns true on success, false on failure (in which case, the string
113113
// is left unchanged). if the argument is null or invalid, the
114114
// concatenation is considered unsuccessful.
115-
unsigned char concat(const String &str);
116-
unsigned char concat(const char *cstr);
117-
unsigned char concat(const char *cstr, unsigned int length);
118-
unsigned char concat(const uint8_t *cstr, unsigned int length) {return concat((const char*)cstr, length);}
119-
unsigned char concat(char c);
120-
unsigned char concat(unsigned char c);
121-
unsigned char concat(int num);
122-
unsigned char concat(unsigned int num);
123-
unsigned char concat(long num);
124-
unsigned char concat(unsigned long num);
125-
unsigned char concat(float num);
126-
unsigned char concat(double num);
127-
unsigned char concat(long long num);
128-
unsigned char concat(unsigned long long num);
129-
unsigned char concat(const __FlashStringHelper * str);
115+
bool concat(const String &str);
116+
bool concat(const char *cstr);
117+
bool concat(const char *cstr, unsigned int length);
118+
bool concat(const uint8_t *cstr, unsigned int length) {return concat((const char*)cstr, length);}
119+
bool concat(char c);
120+
bool concat(unsigned char c);
121+
bool concat(int num);
122+
bool concat(unsigned int num);
123+
bool concat(long num);
124+
bool concat(unsigned long num);
125+
bool concat(float num);
126+
bool concat(double num);
127+
bool concat(long long num);
128+
bool concat(unsigned long long num);
129+
bool concat(const __FlashStringHelper * str);
130130

131131
// if there's not enough memory for the concatenated value, the string
132132
// will be left unchanged (but this isn't signalled in any way)
@@ -202,39 +202,39 @@ class String {
202202
return buffer() ? &String::StringIfHelper : 0;
203203
}
204204
int compareTo(const String &s) const;
205-
unsigned char equals(const String &s) const;
206-
unsigned char equals(const char *cstr) const;
207-
unsigned char operator ==(const String &rhs) const {
205+
bool equals(const String &s) const;
206+
bool equals(const char *cstr) const;
207+
bool operator ==(const String &rhs) const {
208208
return equals(rhs);
209209
}
210-
unsigned char operator ==(const char *cstr) const {
210+
bool operator ==(const char *cstr) const {
211211
return equals(cstr);
212212
}
213-
unsigned char operator !=(const String &rhs) const {
213+
bool operator !=(const String &rhs) const {
214214
return !equals(rhs);
215215
}
216-
unsigned char operator !=(const char *cstr) const {
216+
bool operator !=(const char *cstr) const {
217217
return !equals(cstr);
218218
}
219-
unsigned char operator <(const String &rhs) const;
220-
unsigned char operator >(const String &rhs) const;
221-
unsigned char operator <=(const String &rhs) const;
222-
unsigned char operator >=(const String &rhs) const;
223-
unsigned char equalsIgnoreCase(const String &s) const;
219+
bool operator <(const String &rhs) const;
220+
bool operator >(const String &rhs) const;
221+
bool operator <=(const String &rhs) const;
222+
bool operator >=(const String &rhs) const;
223+
bool equalsIgnoreCase(const String &s) const;
224224
unsigned char equalsConstantTime(const String &s) const;
225-
unsigned char startsWith(const String &prefix) const;
226-
unsigned char startsWith(const char *prefix) const {
225+
bool startsWith(const String &prefix) const;
226+
bool startsWith(const char *prefix) const {
227227
return this->startsWith(String(prefix));
228228
}
229-
unsigned char startsWith(const __FlashStringHelper *prefix) const {
229+
bool startsWith(const __FlashStringHelper *prefix) const {
230230
return this->startsWith(String(prefix));
231231
}
232-
unsigned char startsWith(const String &prefix, unsigned int offset) const;
233-
unsigned char endsWith(const String &suffix) const;
234-
unsigned char endsWith(const char *suffix) const {
232+
bool startsWith(const String &prefix, unsigned int offset) const;
233+
bool endsWith(const String &suffix) const;
234+
bool endsWith(const char *suffix) const {
235235
return this->endsWith(String(suffix));
236236
}
237-
unsigned char endsWith(const __FlashStringHelper * suffix) const {
237+
bool endsWith(const __FlashStringHelper * suffix) const {
238238
return this->endsWith(String(suffix));
239239
}
240240

@@ -345,7 +345,7 @@ class String {
345345
protected:
346346
void init(void);
347347
void invalidate(void);
348-
unsigned char changeBuffer(unsigned int maxStrLen);
348+
bool changeBuffer(unsigned int maxStrLen);
349349

350350
// copy and move
351351
String & copy(const char *cstr, unsigned int length);
Binary file not shown.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# ESP-IDF Partition Table
2+
# Name, Type, SubType, Offset, Size, Flags
3+
# bootloader.bin,, 0x1000, 32K
4+
# partition table, 0x8000, 4K
5+
6+
nvs, data, nvs, 0x9000, 20K,
7+
otadata, data, ota, 0xe000, 8K,
8+
ota_0, 0, ota_0, 0x10000, 1408K,
9+
ota_1, 0, ota_1, 0x170000, 1408K,
10+
uf2, app, factory,0x2d0000, 256K,
11+
ffat, data, fat, 0x310000, 960K,
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#ifndef Pins_Arduino_h
2+
#define Pins_Arduino_h
3+
4+
#include <stdint.h>
5+
6+
7+
#define USB_VID 0x239A
8+
#define USB_PID 0x8123
9+
#define USB_MANUFACTURER "Adafruit"
10+
#define USB_PRODUCT "Feather ESP32-S3 Reverse TFT"
11+
#define USB_SERIAL "" // Empty string for MAC adddress
12+
13+
14+
#define EXTERNAL_NUM_INTERRUPTS 46
15+
#define NUM_DIGITAL_PINS 48
16+
#define NUM_ANALOG_INPUTS 20
17+
18+
#define analogInputToDigitalPin(p) (((p)<20)?(analogChannelToDigitalPin(p)):-1)
19+
#define digitalPinToInterrupt(p) (((p)<48)?(p):-1)
20+
#define digitalPinHasPWM(p) (p < 46)
21+
22+
#define LED_BUILTIN 13
23+
24+
#define PIN_NEOPIXEL 33
25+
#define NEOPIXEL_NUM 1 // number of neopixels
26+
#define NEOPIXEL_POWER 21 // power pin
27+
#define NEOPIXEL_POWER_ON HIGH // power pin state when on
28+
29+
#define TFT_I2C_POWER 7
30+
#define TFT_CS 42
31+
#define TFT_RST 41
32+
#define TFT_DC 40
33+
#define TFT_BACKLITE 45
34+
35+
static const uint8_t SDA = 3;
36+
static const uint8_t SCL = 4;
37+
38+
static const uint8_t SS = 42;
39+
static const uint8_t MOSI = 35;
40+
static const uint8_t SCK = 36;
41+
static const uint8_t MISO = 37;
42+
43+
static const uint8_t A0 = 18;
44+
static const uint8_t A1 = 17;
45+
static const uint8_t A2 = 16;
46+
static const uint8_t A3 = 15;
47+
static const uint8_t A4 = 14;
48+
static const uint8_t A5 = 8;
49+
50+
static const uint8_t TX = 39;
51+
static const uint8_t RX = 38;
52+
#define TX1 TX
53+
#define RX1 RX
54+
55+
static const uint8_t T5 = 5;
56+
static const uint8_t T6 = 6;
57+
static const uint8_t T8 = 8;
58+
static const uint8_t T9 = 9;
59+
static const uint8_t T10 = 10;
60+
static const uint8_t T11 = 11;
61+
static const uint8_t T12 = 12;
62+
static const uint8_t T13 = 13;
63+
static const uint8_t T14 = 14;
64+
65+
static const uint8_t DAC1 = 17;
66+
static const uint8_t DAC2 = 18;
67+
68+
#endif /* Pins_Arduino_h */
Binary file not shown.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2021 Ha Thach (tinyusb.org) for Adafruit Industries
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
25+
26+
#include "esp32-hal-gpio.h"
27+
#include "pins_arduino.h"
28+
29+
extern "C" {
30+
31+
// Initialize variant/board, called before setup()
32+
void initVariant(void)
33+
{
34+
// This board has power control pins, and we must set them to output and high
35+
// in order to enable the NeoPixels, TFT & I2C
36+
pinMode(NEOPIXEL_POWER, OUTPUT);
37+
digitalWrite(NEOPIXEL_POWER, HIGH);
38+
pinMode(TFT_I2C_POWER, OUTPUT);
39+
digitalWrite(TFT_I2C_POWER, HIGH);
40+
}
41+
42+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#ifndef Pins_Arduino_h
2+
#define Pins_Arduino_h
3+
4+
#include <stdint.h>
5+
6+
#define USB_VID 0x303a
7+
#define USB_PID 0x814D // for user apps (https://github.com/espressif/usb-pids/pull/77)
8+
#define USB_MANUFACTURER "Crabik"
9+
#define USB_PRODUCT "Slot ESP32-S3"
10+
#define USB_SERIAL ""
11+
12+
#define EXTERNAL_NUM_INTERRUPTS 46
13+
#define NUM_DIGITAL_PINS 48
14+
#define NUM_ANALOG_INPUTS 20
15+
16+
#define analogInputToDigitalPin(p) (((p)<20)?(analogChannelToDigitalPin(p)):-1)
17+
#define digitalPinToInterrupt(p) (((p)<48)?(p):-1)
18+
#define digitalPinHasPWM(p) (p < 46)
19+
20+
static const uint8_t LED_BUILTIN = 21;
21+
#define BUILTIN_LED LED_BUILTIN // backward compatibility
22+
#define LED_BUILTIN LED_BUILTIN
23+
24+
static const uint8_t S1 = 1;
25+
static const uint8_t S2 = 12;
26+
static const uint8_t S3 = 2;
27+
static const uint8_t S4 = 11;
28+
static const uint8_t S5 = 17;
29+
static const uint8_t S6 = 18;
30+
static const uint8_t S7 = 3;
31+
static const uint8_t S8 = 4;
32+
static const uint8_t S9 = 5;
33+
static const uint8_t S10 = 6;
34+
static const uint8_t S11 = 7;
35+
static const uint8_t S12 = 8;
36+
static const uint8_t S13 = 9;
37+
static const uint8_t S14 = 10;
38+
static const uint8_t S15 = 45;
39+
static const uint8_t S16 = 46;
40+
static const uint8_t S17 = 48;
41+
static const uint8_t S18 = 47;
42+
static const uint8_t S19 = 33;
43+
static const uint8_t S20 = 34;
44+
45+
static const uint8_t TX = S12;
46+
static const uint8_t RX = S11;
47+
#define TX1 TX
48+
#define RX1 RX
49+
50+
static const uint8_t SDA = 13;
51+
static const uint8_t SCL = 14;
52+
static const uint8_t D = SDA;
53+
static const uint8_t C = SCL;
54+
55+
static const uint8_t MOSI = 35;
56+
static const uint8_t MISO = 37;
57+
static const uint8_t SCK = 36;
58+
static const uint8_t DO = MOSI;
59+
static const uint8_t DI = MISO;
60+
static const uint8_t CLK = SCK;
61+
static const uint8_t CS1 = S5;
62+
static const uint8_t CS2 = S6;
63+
static const uint8_t SS = CS1;
64+
65+
static const uint8_t T1 = 1;
66+
static const uint8_t T2 = 2;
67+
static const uint8_t T3 = 3;
68+
static const uint8_t T4 = 4;
69+
static const uint8_t T5 = 5;
70+
static const uint8_t T6 = 6;
71+
static const uint8_t T7 = 7;
72+
static const uint8_t T8 = 8;
73+
static const uint8_t T9 = 9;
74+
static const uint8_t T10 = 10;
75+
static const uint8_t T11 = 11;
76+
static const uint8_t T12 = 12;
77+
78+
static const uint8_t USB_DN = 19;
79+
static const uint8_t USB_DP = 20;
80+
81+
static const uint8_t BOOT_BTN = 0;
82+
static const uint8_t USER_LED = LED_BUILTIN;
83+
84+
static const uint8_t EN_TROYKA = 15;
85+
86+
static const uint8_t LIPO_ALERT = 16;
87+
88+
#endif /* Pins_Arduino_h */
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#ifndef Pins_Arduino_h
2+
#define Pins_Arduino_h
3+
4+
#include <stdint.h>
5+
#include "soc/soc_caps.h"
6+
7+
#define USB_VID 0x303a
8+
#define USB_PID 0x1001
9+
10+
#define EXTERNAL_NUM_INTERRUPTS 46
11+
#define NUM_DIGITAL_PINS 48
12+
#define NUM_ANALOG_INPUTS 20
13+
14+
#define analogInputToDigitalPin(p) (((p)<20)?(analogChannelToDigitalPin(p)):-1)
15+
#define digitalPinToInterrupt(p) (((p)<48)?(p):-1)
16+
#define digitalPinHasPWM(p) (p < 46)
17+
18+
static const uint8_t BUTTON_1 = 0;
19+
static const uint8_t BUTTON_2 = 14;
20+
static const uint8_t BAT_VOLT = 4;
21+
22+
static const uint8_t TX = 43;
23+
static const uint8_t RX = 44;
24+
25+
static const uint8_t SDA = 18;
26+
static const uint8_t SCL = 17;
27+
28+
static const uint8_t SS = 10;
29+
static const uint8_t MOSI = 11;
30+
static const uint8_t MISO = 13;
31+
static const uint8_t SCK = 12;
32+
33+
static const uint8_t TP_RESET = 21;
34+
static const uint8_t TP_INIT = 16;
35+
36+
// ST7789 IPS TFT 170x320
37+
static const uint8_t LCD_BL = 38;
38+
static const uint8_t LCD_D0 = 39;
39+
static const uint8_t LCD_D1 = 40;
40+
static const uint8_t LCD_D2 = 41;
41+
static const uint8_t LCD_D3 = 42;
42+
static const uint8_t LCD_D4 = 45;
43+
static const uint8_t LCD_D5 = 46;
44+
static const uint8_t LCD_D6 = 47;
45+
static const uint8_t LCD_D7 = 48;
46+
static const uint8_t LCD_WR = 8;
47+
static const uint8_t LCD_RD = 9;
48+
static const uint8_t LCD_DC = 7;
49+
static const uint8_t LCD_CS = 6;
50+
static const uint8_t LCD_RES = 5;
51+
static const uint8_t LCD_POWER_ON = 15;
52+
53+
// P1
54+
static const uint8_t PIN_43 = 43;
55+
static const uint8_t PIN_44 = 44;
56+
static const uint8_t PIN_18 = 18;
57+
static const uint8_t PIN_17 = 17;
58+
static const uint8_t PIN_21 = 21;
59+
static const uint8_t PIN_16 = 16;
60+
61+
// P2
62+
static const uint8_t PIN_1 = 1;
63+
static const uint8_t PIN_2 = 2;
64+
static const uint8_t PIN_3 = 3;
65+
static const uint8_t PIN_10 = 10;
66+
static const uint8_t PIN_11 = 11;
67+
static const uint8_t PIN_12 = 12;
68+
static const uint8_t PIN_13 = 13;
69+
70+
// Analog
71+
static const uint8_t A0 = 1;
72+
static const uint8_t A1 = 2;
73+
static const uint8_t A2 = 3;
74+
static const uint8_t A9 = 10;
75+
static const uint8_t A10 = 11;
76+
static const uint8_t A11 = 12;
77+
static const uint8_t A12 = 13;
78+
static const uint8_t A15 = 16;
79+
static const uint8_t A16 = 17;
80+
static const uint8_t A17 = 18;
81+
82+
83+
// Touch
84+
static const uint8_t T1 = 1;
85+
static const uint8_t T2 = 2;
86+
static const uint8_t T3 = 3;
87+
static const uint8_t T10 = 10;
88+
static const uint8_t T11 = 11;
89+
static const uint8_t T12 = 12;
90+
static const uint8_t T13 = 13;
91+
92+
#endif /* Pins_Arduino_h */
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#ifndef Pins_Arduino_h
2+
#define Pins_Arduino_h
3+
4+
#include <stdint.h>
5+
6+
#define EXTERNAL_NUM_INTERRUPTS 16
7+
#define NUM_DIGITAL_PINS 20
8+
#define NUM_ANALOG_INPUTS 16
9+
10+
#define analogInputToDigitalPin(p) (((p)<20)?(analogChannelToDigitalPin(p)):-1)
11+
#define digitalPinToInterrupt(p) (((p)<40)?(p):-1)
12+
#define digitalPinHasPWM(p) (p < 34)
13+
14+
15+
// Motor driver pins
16+
#define MOTOR_A_IN1 25 // PHASE/IN1
17+
#define MOTOR_A_IN2 26 // ENABLE/IN2
18+
19+
#define MOTOR_B_IN1 27 // PHASE/IN1
20+
#define MOTOR_B_IN2 32 // ENABLE/IN2
21+
22+
#define MOTOR_C_IN1 33 // PHASE/IN1
23+
#define MOTOR_C_IN2 4 // ENABLE/IN2
24+
25+
#define SLEEP_MOTOR_ABC 2 // nSLEEP
26+
27+
#define LED_ROBOHEART 14 // Built in LED
28+
#define BUILTIN_LED LED_ROBOHEART // backward compatibility
29+
#define LED_BUILTIN LED_ROBOHEART
30+
31+
#define BUTTON_ROBOHEART 0 // Button
32+
33+
// I2C IMU sensor
34+
#define IMU_SDA 21
35+
#define IMU_SCL 22
36+
37+
#define RXD1 16
38+
#define TXD1 17
39+
40+
// GSM Vela connector board pins
41+
#define GSM_PWRKEY 12
42+
#define GSM_DTR 13
43+
#define GSM_CTS 15
44+
#define GSM_RTS 14
45+
#define GSM_TX TXD1
46+
#define GSM_RX RXD1
47+
#define BATTERY_PIN 36 // Battery ADC pin
48+
49+
static const uint8_t TX = 35;
50+
static const uint8_t RX = 34;
51+
52+
static const uint8_t TXD2 = 17;
53+
static const uint8_t RXD2 = 16;
54+
55+
static const uint8_t SDA = 21;
56+
static const uint8_t SCL = 22;
57+
58+
static const uint8_t SS = 5;
59+
static const uint8_t MOSI = 23;
60+
static const uint8_t MISO = 19;
61+
static const uint8_t SCK = 18;
62+
63+
static const uint8_t G23 = 23;
64+
static const uint8_t G19 = 19;
65+
static const uint8_t G18 = 18;
66+
static const uint8_t G3 = 3;
67+
static const uint8_t G16 = 16;
68+
static const uint8_t G21 = 21;
69+
static const uint8_t G2 = 2;
70+
static const uint8_t G12 = 12;
71+
static const uint8_t G15 = 15;
72+
static const uint8_t G35 = 35;
73+
static const uint8_t G36 = 36;
74+
static const uint8_t G25 = 25;
75+
static const uint8_t G26 = 26;
76+
static const uint8_t G1 = 1;
77+
static const uint8_t G17 = 17;
78+
static const uint8_t G22 = 22;
79+
static const uint8_t G5 = 5;
80+
static const uint8_t G13 = 13;
81+
static const uint8_t G0 = 0;
82+
static const uint8_t G34 = 34;
83+
84+
static const uint8_t DAC1 = 25;
85+
static const uint8_t DAC2 = 26;
86+
87+
static const uint8_t A0 = 36;
88+
static const uint8_t A3 = 39;
89+
static const uint8_t A4 = 32;
90+
static const uint8_t A5 = 33;
91+
static const uint8_t A6 = 34;
92+
static const uint8_t A7 = 35;
93+
static const uint8_t A10 = 4;
94+
static const uint8_t A11 = 0;
95+
static const uint8_t A12 = 2;
96+
static const uint8_t A13 = 15;
97+
static const uint8_t A14 = 13;
98+
static const uint8_t A15 = 12;
99+
static const uint8_t A16 = 14;
100+
static const uint8_t A17 = 27;
101+
static const uint8_t A18 = 25;
102+
static const uint8_t A19 = 26;
103+
104+
#endif /* Pins_Arduino_h */

0 commit comments

Comments
 (0)
Please sign in to comment.