add esp32

This commit is contained in:
lady ada 2022-01-08 18:52:08 -05:00
parent fe752fc5a0
commit c6a173d764
5 changed files with 1001 additions and 775 deletions

View file

@ -79,6 +79,12 @@ RP2040 does not have official Arduino support (yet).
```python3 parser.py "Adafruit FunHouse.fzpz" path/to/circuitpython/ports/espressif/boards/adafruit_funhouse/pins.c esp32s2pins.csv -s "^D([0-9])" "IO\1"```
#### ESP32:
```python3 parser.py "Adafruit QT Py ESP32 Pico.fzpz" None -a ../../ArduinoSketches/hardware/espressif/esp32/variants/adafruit_qtpy_esp32 esp32pins.csv```
#### nRF52:
```python3 parser.py "Adafruit Feather nRF52840.fzpz" path/to/circuitpython/ports/nrf/boards/feather_nrf52840_express/pins.c nrf52840pins.csv -a ~/Library/Arduino15/packages/adafruit/hardware/nrf52/0.20.5/variants/feather_nrf52840_express```

57
esp32pins.csv Normal file
View file

@ -0,0 +1,57 @@
GPIO,ADC,HS/QSPI,SDMMC,Touch,RTC,UART,Other,Input Only?
0,ADC2_CH1,,,T1,RTC11,,CLK_OUT1,
1,,,,,,U0TXD,CLK_OUT3,
2,ADC2_CH2,HSPIWP,HS2_DATA0,T2,RTC12,,,
3,,,,,,U0RXD,CLK_OUT2,
4,ADC2_CH0,HSPIHD,HS2_DATA1,T0,RTC10,,,
5,,VSPICS0,HS1_DATA6,,,,,
6,,SPICLK,HS1_CLK,,,U1CTS,,
7,,SPIQ,HS1_DATA0,,,U2RTS,,
8,,SPID,HS1_DATA1,,,U2CTS,,
9,,SPIHD,HS1_DATA2,,,U1RXD,,
10,,SPIWP,HS1_DATA3,,,U1TXD,,
11,,SPI_CS0,HS1_CMD,,,U1RTS,,
12,ADC2_CH5,HSPIQ,HS2_DATA2,T5,RTC15,,MTDI,
13,ADC2_CH4,HSPID,HS2_DATA3,T4,RTC14,,MTCK,
14,ADC2_CH6,HSPICLK,HS2_CLK,T6,RTC16,,MTMS,
15,ADC2_CH3,HSPICS0,HS2_CMD,T3,RTC13,,MTDO,
16,,,HS1_DATA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_CH5 HSPIQ HS2_DATA2 T5 RTC15 MTDI
15 13 ADC2_CH4 HSPID HS2_DATA3 T4 RTC14 MTCK
16 14 ADC2_CH6 HSPICLK HS2_CLK T6 RTC16 MTMS
17 15 ADC2_CH3 HSPICS0 HS2_CMD T3 RTC13 MTDO
18 16 HS1_DATA4 U2RXD
19 17 HS1_DATA5 U2TXD
20 18 VSPICLK HS1_DATA7
21 19 VSPIQ U0CTS
22 20
23 21 VSPIHD
24 22 VSPIWP U0RTS
25 23 VSPID HS1_STROBE
26 25 ADC2_CH8 RTC6 DAC1
27 26 ADC2_CH9 RTC7 DAC2
28 27 ADC2_CH7 T7 RTC17
29 32 ADC1_CH4 T9 RTC9 32K_XP
30 33 ADC1_CH5 T8 RTC8 32K_XN
31 34 ADC1_CH6 RTC4 VDET1 Yes
32 35 ADC1_CH7 RTC5 VDET2 Yes
33 36 ADC1_CH0 RTC0 SENSE_V+- Yes
34 37 ADC1_CH1 RTC1 SENSE_CAP+- Yes
35 38 ADC1_CH2 RTC2 SENSE_CAP+AC0- Yes
36 39 ADC1_CH3 RTC3 SENSE_V+AC0- Yes
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57 DESCRIPTION

1636
output.svg

File diff suppressed because it is too large Load diff

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 87 KiB

View file

@ -191,8 +191,7 @@ def get_arduino_mapping(connections, variantfolder):
global longest_arduinopin
if not variantfolder:
return connections
# special case of very early chips
###################################################### special case of very early chips
if ("atmega328" in variantfolder) or ("atmega32u4" in variantfolder) or ("attiny8x" in variantfolder):
pinmap8x = ["PB0", "PB1", "PB2", "PB3", "PB4"]
pinmap328 = ["PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7",
@ -237,8 +236,8 @@ def get_arduino_mapping(connections, variantfolder):
#print(connections)
return connections
# NRF52 board variant handler
if "nrf52" in variantfolder.lower():
###################################################### NRF52 board variant handler
elif "nrf52" in variantfolder.lower():
# copy over the variant.cpp minus any includes
variantcpp = open(variantfolder+"/"+"variant.cpp").readlines()
@ -292,8 +291,8 @@ int main(void) {
outfileh.write(line)
outfileh.close()
# SAMDxx board variant handler
if "samd" in variantfolder.lower():
###################################################### SAMDxx board variant handler
elif "samd" in variantfolder.lower():
# copy over the variant.cpp minus any includes
variantcpp = open(variantfolder+"/"+"variant.cpp").readlines()
@ -403,15 +402,55 @@ int main(void) {
outfileh.close()
time.sleep(1)
# now compile it!
compileit = subprocess.Popen("g++ -w variant.cpp -o arduinopins", shell=True, stdout=subprocess.PIPE)
#print(compileit.stdout.read())
runit = subprocess.Popen("./arduinopins", shell=True, stdout=subprocess.PIPE)
time.sleep(1)
arduinopins = runit.stdout.read().decode("utf-8")
#print(arduinopins)
#exit()
###################################################### SAMDxx board variant handler
elif "esp32" in variantfolder.lower():
for conn in connections:
#print(conn['name'])
# digital pins
matches1 = re.match(r'(GPIO|IO|D|#)([0-9]+)', conn['name'])
if matches1:
#print(matches)
digitalname = matches1.group(2)
conn['pinname'] = pinmap[int(digitalname)]
conn['arduinopin'] = digitalname
longest_arduinopin = max(longest_arduinopin, len(digitalname))
else:
conn['pinname'] = conn['name']
# open the file
varianth = open(variantfolder+"/"+"pins_arduino.h").readlines()
arduinopins = ""
for line in varianth:
#print(line)
# find the const defines
matches2 = re.match(r'\s*static\s*const\s*uint8_t\s*([A-Z0-9_]+)\s*=\s*([0-9]+)\s*;.*', line)
if matches2:
prettyname = matches2[1]
pinnumber = matches2[2]
print(prettyname, pinnumber)
for conn in connections:
if conn['pinname'] == prettyname:
conn['pinname'] = pinnumber
#conn['arduinopin'] = pinnumber
print(conn)
arduinopins += matches2[2] + ", " + matches2[1] + "\n"
#exit()
#print(arduinopins)
else:
raise UnimplementedError("Unknown arduino variant type!", variantfolder.lower())
if not arduinopins: # some variants can auto-extract the pins for us, if not we do it the hard way
time.sleep(1)
# now compile it!
compileit = subprocess.Popen("g++ -w variant.cpp -o arduinopins", shell=True, stdout=subprocess.PIPE)
#print(compileit.stdout.read())
runit = subprocess.Popen("./arduinopins", shell=True, stdout=subprocess.PIPE)
time.sleep(1)
arduinopins = runit.stdout.read().decode("utf-8")
#print(arduinopins)
#exit()
for pinpair in arduinopins.split("\n"):
if not pinpair:
continue
@ -420,8 +459,8 @@ int main(void) {
if 'arduinopin' in conn:
continue
conn['arduinopin'] = arduinopin
#print(arduinopin, pinname, conn)
longest_arduinopin = max(longest_arduinopin, len(arduinopin))
#print(arduinopin, pinname, connection)
return connections
@ -765,6 +804,8 @@ def draw_pinlabels_svg(connections):
label_type = 'High Speed'
elif mux == 'Low Speed':
label_type = 'Low Speed'
elif mux == 'RTC':
label_type = 'Low Speed'
elif mux == 'Speed':
label_type = 'Speed'
elif mux in('Special', 'SPECIAL'):
@ -781,6 +822,8 @@ def draw_pinlabels_svg(connections):
label_type = 'Timer'
elif mux == 'Timer Alt':
label_type = 'Timer Alt'
elif mux == 'SDMMC':
label_type = 'SERCOM'
else:
continue

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 26 KiB