add atmega328 support

This commit is contained in:
lady ada 2021-10-12 14:27:48 -04:00
parent eedf674bfa
commit e59b4996b2
4 changed files with 1269 additions and 2262 deletions

26
atmega328pins.csv Normal file
View file

@ -0,0 +1,26 @@
GPIO,ADC,Other,PWM
PD0,,RX,
PD1,,TX,
PD2,,INT0,
PD3,,INT1,OC2B
PD4,,,
PD5,,,OC0B
PD6,,,OC0A
PD7,,,
PB0,,,
PB1,,,OC1A
PB2,,SS,OC1B
PB3,,MOSI,OC2A
PB4,,MISO,
PB5,,SCK,
PC0,A0,,
PC1,A1,,
PC2,A2,,
PC3,A3,,
PC4,A4,SDA,
PC5,A5,SCL,
A6,A6,,
A7,A7,,
,,,
,,,
DESCRIPTION,,,
1 GPIO ADC Other PWM
2 PD0 RX
3 PD1 TX
4 PD2 INT0
5 PD3 INT1 OC2B
6 PD4
7 PD5 OC0B
8 PD6 OC0A
9 PD7
10 PB0
11 PB1 OC1A
12 PB2 SS OC1B
13 PB3 MOSI OC2A
14 PB4 MISO
15 PB5 SCK
16 PC0 A0
17 PC1 A1
18 PC2 A2
19 PC3 A3
20 PC4 A4 SDA
21 PC5 A5 SCL
22 A6 A6
23 A7 A7
24
25
26 DESCRIPTION

2721
output.svg

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 148 KiB

After

Width:  |  Height:  |  Size: 92 KiB

View file

@ -192,6 +192,33 @@ def get_arduino_mapping(connections, variantfolder):
if not variantfolder:
return connections
# special case of very early chips
if "atmega328" in variantfolder:
pinmap = ["PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7",
"PB0", "PB1", "PB2", "PB3", "PB4", "PB5",
"PC0", "PC1", "PC2", "PC3", "PC4", "PC5"]
for conn in connections:
print(conn['name'])
# digital pins
matches = re.match(r'(IO|D)([0-9]+)', conn['name'])
if matches:
digitalname = matches.group(2)
conn['pinname'] = pinmap[int(digitalname)]
conn['arduinopin'] = digitalname
longest_arduinopin = max(longest_arduinopin, len(digitalname))
# analog pins
matches = re.match(r'(AD)([0-9]+)', conn['name'])
if matches:
analogname = matches.group(2)
digitalname = str(14 + int(analogname))
conn['pinname'] = pinmap[int(digitalname)]
conn['arduinopin'] = digitalname
longest_arduinopin = max(longest_arduinopin, len(digitalname))
#print(connections)
return connections
# NRF52 board variant handler
if "nrf52" in variantfolder.lower():
# copy over the variant.cpp minus any includes
@ -365,7 +392,7 @@ int main(void) {
runit = subprocess.Popen("./arduinopins", shell=True, stdout=subprocess.PIPE)
time.sleep(1)
arduinopins = runit.stdout.read().decode("utf-8")
print(arduinopins)
#print(arduinopins)
#exit()
for pinpair in arduinopins.split("\n"):
if not pinpair:
@ -879,10 +906,15 @@ def parse(fzpz, circuitpydef, pinoutcsv, arduinovariantfolder, substitute):
# find the 'true' GPIO pin names via the circuitpython file
# e.g. "MISO" and "D2" map to "GPIO03" or "P0.04"
if circuitpydef != "None":
connections = get_circuitpy_aliases(connections, circuitpydef)
# find the mapping between gpio pins and arduino pins
# atmega 328's dont have a mapping
if not arduinovariantfolder and pinoutcsv == "atmega328pins.csv":
arduinovariantfolder = "atmega328"
connections = get_arduino_mapping(connections, arduinovariantfolder)
#print(connections)
# open and parse the pinout mapper CSV
pinarray = get_chip_pinout(connections, pinoutcsv)
@ -942,7 +974,9 @@ def parse(fzpz, circuitpydef, pinoutcsv, arduinovariantfolder, substitute):
if not 'pinname' in conn:
continue
# find muxes next
muxes = next((pin for pin in pinarray if pin['GPIO'] == conn['pinname']), None)
#print("***", muxes)
conn['mux'] = muxes
draw_pinlabels_svg(connections)

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 28 KiB