Add support for STM32F10x

Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
This commit is contained in:
Frederic Pillon 2017-08-19 13:10:02 +02:00
parent e7753e44d8
commit d4f2c75843
3 changed files with 665 additions and 607 deletions

View file

@ -5,7 +5,8 @@
python genpinmap_arduino.py NUCLEO_F030R8 "STM32F030R8Tx.xml" python genpinmap_arduino.py NUCLEO_F030R8 "STM32F030R8Tx.xml"
python genpinmap_arduino.py NUCLEO_F091RC "STM32F091R(B-C)Tx.xml" python genpinmap_arduino.py NUCLEO_F091RC "STM32F091R(B-C)Tx.xml"
#python genpinmap_arduino.py NUCLEO_F103RB "STM32F103R(8-B)Tx.xml" python genpinmap_arduino.py DISCO_F100RB "STM32F100R(8-B)Tx.xml"
python genpinmap_arduino.py NUCLEO_F103RB "STM32F103R(8-B)Tx.xml"
python genpinmap_arduino.py NUCLEO_F207ZG "STM32F207Z(C-E-F-G)Tx.xml" python genpinmap_arduino.py NUCLEO_F207ZG "STM32F207Z(C-E-F-G)Tx.xml"
python genpinmap_arduino.py NUCLEO_F303RE "STM32F303R(D-E)Tx.xml" python genpinmap_arduino.py NUCLEO_F303RE "STM32F303R(D-E)Tx.xml"
python genpinmap_arduino.py NUCLEO_F401RE "STM32F401R(D-E)Tx.xml" python genpinmap_arduino.py NUCLEO_F401RE "STM32F401R(D-E)Tx.xml"

View file

@ -33,6 +33,8 @@ def find_gpio_file(xmldoc):
return res return res
def get_gpio_af_num(xml, pintofind, iptofind): def get_gpio_af_num(xml, pintofind, iptofind):
if 'STM32F10' in sys.argv[2]:
return get_gpio_af_numF1(xml, pintofind, iptofind)
# xml = parse('GPIO-STM32L051_gpio_v1_0_Modes.xml') # xml = parse('GPIO-STM32L051_gpio_v1_0_Modes.xml')
#xml = parse(gpiofile) #xml = parse(gpiofile)
#DBG print ('pin to find ' + pintofind) #DBG print ('pin to find ' + pintofind)
@ -42,36 +44,83 @@ def get_gpio_af_num(xml, pintofind, iptofind):
i += 1 i += 1
j = 0 j = 0
if n.nodeType == Node.ELEMENT_NODE: if n.nodeType == Node.ELEMENT_NODE:
for premlevel in n.attributes.items(): for firstlevel in n.attributes.items():
# if 'PB7' in premlevel: # if 'PB7' in firstlevel:
if pintofind == premlevel[1]: if pintofind == firstlevel[1]:
#DBG print (i , premlevel) #DBG print (i , firstlevel)
#n = noeud de la pin recherchee #n = pin node found
for m in n.childNodes: for m in n.childNodes:
j += 1 j += 1
k = 0 k = 0
if m.nodeType == Node.ELEMENT_NODE: if m.nodeType == Node.ELEMENT_NODE:
for deuzlevel in m.attributes.items(): for secondlevel in m.attributes.items():
k += 1 k += 1
# if 'I2C1_SDA' in deuzlevel: # if 'I2C1_SDA' in secondlevel:
if iptofind in deuzlevel: if iptofind in secondlevel:
#DBG print (i, j, m.attributes.items()) #DBG print (i, j, m.attributes.items())
# m = noeud de l'IP recherchee # m = IP node found
for p in m.childNodes: for p in m.childNodes:
if p.nodeType == Node.ELEMENT_NODE: if p.nodeType == Node.ELEMENT_NODE:
#p noeud du 'Specific parameter' #p node of 'Specific parameter'
#DBG print (i,j,k,p.attributes.items()) #DBG print (i,j,k,p.attributes.items())
for myc in p.childNodes: for myc in p.childNodes:
#DBG print (myc) #DBG print (myc)
if myc.nodeType == Node.ELEMENT_NODE: if myc.nodeType == Node.ELEMENT_NODE:
#myc = noeud du ALTERNATE !!! ENFIN !!! #myc = node of ALTERNATE
for mygpioaflist in myc.childNodes: for mygpioaflist in myc.childNodes:
mygpioaf = mygpioaflist.data mygpioaf += ' ' + mygpioaflist.data
#print (mygpioaf) #print (mygpioaf)
if mygpioaf == 'NOTFOUND': if mygpioaf == 'NOTFOUND':
print ('GPIO AF not found in ' + gpiofile + ' for ' + pintofind + ' and the IP ' + iptofind) print ('GPIO AF not found in ' + gpiofile + ' for ' + pintofind + ' and the IP ' + iptofind)
#quit() #quit()
return mygpioaf return mygpioaf.replace('NOTFOUND ', '')
def get_gpio_af_numF1(xml, pintofind, iptofind):
#print ('pin to find ' + pintofind + ' ip to find ' + iptofind)
i=0
mygpioaf = 'NOTFOUND'
for n in xml.documentElement.childNodes:
i += 1
j = 0
if n.nodeType == Node.ELEMENT_NODE:
for firstlevel in n.attributes.items():
#print ('firstlevel ' , firstlevel)
# if 'PB7' in firstlevel:
if pintofind == firstlevel[1]:
#print ('firstlevel ' , i , firstlevel)
#n = pin node found
for m in n.childNodes:
j += 1
k = 0
if m.nodeType == Node.ELEMENT_NODE:
for secondlevel in m.attributes.items():
#print ('secondlevel ' , i, j, k , secondlevel)
k += 1
# if 'I2C1_SDA' in secondlevel:
if iptofind in secondlevel:
# m = IP node found
#print (i, j, m.attributes.items())
if m.hasChildNodes() == False:
mygpioaf = 'AFIO_NONE'
else:
for p in m.childNodes:
#p node 'RemapBlock'
for s in p.childNodes:
if s.nodeType == Node.ELEMENT_NODE:
#s node 'Specific parameter'
#DBG print (i,j,k,p.attributes.items())
for myc in s.childNodes:
#DBG print (myc)
if myc.nodeType == Node.ELEMENT_NODE:
#myc = AF value
for mygpioaflist in myc.childNodes:
mygpioaf += ' ' + mygpioaflist.data.replace("__HAL_", "").replace("_REMAP", "")
#print mygpioaf
if mygpioaf == 'NOTFOUND':
print ('GPIO AF not found in ' + gpiofile + ' for ' + pintofind + ' and the IP ' + iptofind + ' set as AFIO_NONE')
mygpioaf = 'AFIO_NONE'
return mygpioaf.replace('NOTFOUND ', '')
def store_pin (pin, name): def store_pin (pin, name):
#store pin I/O #store pin I/O
@ -293,8 +342,10 @@ def print_i2c(xml, l):
#2nd element is the I2C XXX signal #2nd element is the I2C XXX signal
b = p[2].split('_')[0] b = p[2].split('_')[0]
s1 += b[:len(b)-1] + b[len(b)-1] + ', STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, ' s1 += b[:len(b)-1] + b[len(b)-1] + ', STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, '
s1 += result + ')},\n' r = result.split(' ')
out_file.write(s1) for af in r:
s2 = s1 + af + ')},\n'
out_file.write(s2)
i += 1 i += 1
out_file.write( """ {NC, NP, 0} out_file.write( """ {NC, NP, 0}
}; };
@ -321,9 +372,11 @@ def print_pwm(xml):
chan = chan.strip('N') chan = chan.strip('N')
else: else:
neg = ', 0' neg = ', 0'
s1 += 'STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, ' + result + ', ' + chan + neg s1 += 'STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, '
s1 += ')}, // ' + p[2] + '\n' r = result.split(' ')
out_file.write(s1) for af in r:
s2 = s1 + af + ', ' + chan + neg + ')}, // ' + p[2] + '\n'
out_file.write(s2)
i += 1 i += 1
out_file.write( """ {NC, NP, 0} out_file.write( """ {NC, NP, 0}
}; };
@ -341,8 +394,11 @@ def print_uart(xml, l):
#2nd element is the UART_XX signal #2nd element is the UART_XX signal
b=p[2].split('_')[0] b=p[2].split('_')[0]
s1 += "%-9s" % (b[:len(b)-1] + b[len(b)-1:] + ',') s1 += "%-9s" % (b[:len(b)-1] + b[len(b)-1:] + ',')
s1 += 'STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, ' + result +')},\n' s1 += 'STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, '
out_file.write(s1) r = result.split(' ')
for af in r:
s2 = s1 + af + ')},\n'
out_file.write(s2)
i += 1 i += 1
out_file.write( """ {NC, NP, 0} out_file.write( """ {NC, NP, 0}
@ -361,8 +417,10 @@ def print_spi(xml, l):
#2nd element is the SPI_XXXX signal #2nd element is the SPI_XXXX signal
instance=p[2].split('_')[0].replace("SPI", "") instance=p[2].split('_')[0].replace("SPI", "")
s1 += 'SPI' + instance + ', STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, ' s1 += 'SPI' + instance + ', STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, '
s1 += result +')},\n' r = result.split(' ')
out_file.write(s1) for af in r:
s2 = s1 + af + ')},\n'
out_file.write(s2)
i += 1 i += 1
out_file.write( """ {NC, NP, 0} out_file.write( """ {NC, NP, 0}
@ -384,8 +442,10 @@ def print_can(xml, l):
#if len(instance) == 0: #if len(instance) == 0:
# instance = '1' # instance = '1'
s1 += 'CAN' + instance + ', STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, ' s1 += 'CAN' + instance + ', STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, '
s1 += result +')},\n' r = result.split(' ')
out_file.write( s1) for af in r:
s2 = s1 + af + ')},\n'
out_file.write(s2)
i += 1 i += 1
out_file.write( """ {NC, NP, 0} out_file.write( """ {NC, NP, 0}
}; };
@ -547,10 +607,6 @@ if (os.path.isfile(output_filename)):
out_file = open(output_filename, 'w') out_file = open(output_filename, 'w')
# Check if Alternate functions in GPIO or old GPIO (no alternate)
if 'STM32F10' in sys.argv[2]:
print ("STM32F10xx MCU not supported due to older GPIO IP version\n")
quit()
gpiofile = find_gpio_file(xmldoc) gpiofile = find_gpio_file(xmldoc)
if gpiofile == 'ERROR': if gpiofile == 'ERROR':

View file

@ -25,7 +25,8 @@ set -o nounset # Treat unset variables as an error
# #
python genpinmap_arduino.py NUCLEO_F030R8 "STM32F030R8Tx.xml" python genpinmap_arduino.py NUCLEO_F030R8 "STM32F030R8Tx.xml"
python genpinmap_arduino.py NUCLEO_F091RC "STM32F091R(B-C)Tx.xml" python genpinmap_arduino.py NUCLEO_F091RC "STM32F091R(B-C)Tx.xml"
#python genpinmap_arduino.py NUCLEO_F103RB "STM32F103R(8-B)Tx.xml" python genpinmap_arduino.py DISCO_F100RB "STM32F100R(8-B)Tx.xml"
python genpinmap_arduino.py NUCLEO_F103RB "STM32F103R(8-B)Tx.xml"
python genpinmap_arduino.py NUCLEO_F207ZG "STM32F207Z(C-E-F-G)Tx.xml" python genpinmap_arduino.py NUCLEO_F207ZG "STM32F207Z(C-E-F-G)Tx.xml"
python genpinmap_arduino.py NUCLEO_F303RE "STM32F303R(D-E)Tx.xml" python genpinmap_arduino.py NUCLEO_F303RE "STM32F303R(D-E)Tx.xml"
python genpinmap_arduino.py NUCLEO_F401RE "STM32F401R(D-E)Tx.xml" python genpinmap_arduino.py NUCLEO_F401RE "STM32F401R(D-E)Tx.xml"