@@ -69,41 +69,42 @@ def get_gpio_af_num(pintofind, iptofind):
69
69
for n in xml_gpio .documentElement .childNodes :
70
70
i += 1
71
71
j = 0
72
- if n .nodeType == Node .ELEMENT_NODE :
73
- for firstlevel in n .attributes .items ():
74
- # if 'PB7' in firstlevel:
75
- if pintofind == firstlevel [1 ]:
76
- # DBG print (i , firstlevel)
77
- # n = pin node found
78
- for m in n .childNodes :
79
- j += 1
80
- k = 0
81
- if m .nodeType == Node .ELEMENT_NODE :
82
- for secondlevel in m .attributes .items ():
83
- k += 1
84
- # if 'I2C1_SDA' in secondlevel:
85
- if iptofind in secondlevel :
86
- # DBG print (i, j, m.attributes.items())
87
- # m = IP node found
88
- for p in m .childNodes :
89
- if p .nodeType == Node .ELEMENT_NODE :
90
- # p node of 'Specific parameter'
91
- # DBG print (i,j,k,p.attributes.items())
92
- for myc in p .childNodes :
93
- # DBG print (myc)
94
- if myc .nodeType == Node .ELEMENT_NODE :
95
- # myc = node of ALTERNATE
96
- for mygpioaflist in myc .childNodes :
97
- if (
98
- mygpioaflist .data
99
- not in mygpioaf
100
- ):
101
- if mygpioaf != "" :
102
- mygpioaf += " "
103
- mygpioaf += (
104
- mygpioaflist .data
105
- )
106
- # print (mygpioaf)
72
+ if n .nodeType != Node .ELEMENT_NODE :
73
+ continue
74
+ for firstlevel in n .attributes .items ():
75
+ # if 'PB7' in firstlevel:
76
+ if pintofind != firstlevel [1 ]:
77
+ continue
78
+ # DBG print (i , firstlevel)
79
+ # n = pin node found
80
+ for m in n .childNodes :
81
+ j += 1
82
+ k = 0
83
+ if m .nodeType != Node .ELEMENT_NODE :
84
+ continue
85
+ for secondlevel in m .attributes .items ():
86
+ k += 1
87
+ # if 'I2C1_SDA' in secondlevel:
88
+ if iptofind not in secondlevel :
89
+ continue
90
+ # DBG print (i, j, m.attributes.items())
91
+ # m = IP node found
92
+ for p in m .childNodes :
93
+ if p .nodeType != Node .ELEMENT_NODE :
94
+ continue
95
+ # p node of 'Specific parameter'
96
+ # DBG print (i,j,k,p.attributes.items())
97
+ for myc in p .childNodes :
98
+ # DBG print (myc)
99
+ if myc .nodeType != Node .ELEMENT_NODE :
100
+ continue
101
+ # myc = node of ALTERNATE
102
+ for mygpioaflist in myc .childNodes :
103
+ if mygpioaflist .data not in mygpioaf :
104
+ if mygpioaf != "" :
105
+ mygpioaf += " "
106
+ mygpioaf += mygpioaflist .data
107
+ # print (mygpioaf)
107
108
if mygpioaf == "" :
108
109
mygpioaf = "GPIO_AF_NONE"
109
110
return mygpioaf
@@ -116,56 +117,55 @@ def get_gpio_af_numF1(pintofind, iptofind):
116
117
for n in xml_gpio .documentElement .childNodes :
117
118
i += 1
118
119
j = 0
119
- if n .nodeType == Node .ELEMENT_NODE :
120
- for firstlevel in n .attributes .items ():
121
- # print ('firstlevel ' , firstlevel)
122
- # if 'PB7' in firstlevel:
123
- if pintofind == firstlevel [1 ]:
124
- # print ('firstlevel ' , i , firstlevel)
125
- # n = pin node found
126
- for m in n .childNodes :
127
- j += 1
128
- k = 0
129
- if m .nodeType == Node .ELEMENT_NODE :
130
- for secondlevel in m .attributes .items ():
131
- # print ('secondlevel ' , i, j, k , secondlevel)
132
- k += 1
133
- # if 'I2C1_SDA' in secondlevel:
134
- if iptofind in secondlevel :
135
- # m = IP node found
136
- # print (i, j, m.attributes.items())
137
- for p in m .childNodes :
138
- # p node 'RemapBlock'
139
- if (
140
- p .nodeType == Node .ELEMENT_NODE
141
- and p .hasChildNodes () is False
142
- ):
143
- if mygpioaf != "" :
144
- mygpioaf += " "
145
- mygpioaf += "AFIO_NONE"
146
- else :
147
- for s in p .childNodes :
148
- if s .nodeType == Node .ELEMENT_NODE :
149
- # s node 'Specific parameter'
150
- # print (i,j,k,p.attributes.items())
151
- for myc in<
F438
/span> s .childNodes :
152
- # DBG print (myc)
153
- if (
154
- myc .nodeType
155
- == Node .ELEMENT_NODE
156
- ):
157
- # myc = AF value
158
- for (
159
- mygpioaflist
160
- ) in myc .childNodes :
161
- if mygpioaf != "" :
162
- mygpioaf += " "
163
- mygpioaf += mygpioaflist .data .replace (
164
- "__HAL_" , ""
165
- ).replace (
166
- "_REMAP" , ""
167
- )
168
- # print mygpioaf
120
+ if n .nodeType != Node .ELEMENT_NODE :
121
+ continue
122
+ for firstlevel in n .attributes .items ():
123
+ # print ('firstlevel ' , firstlevel)
124
+ # if 'PB7' in firstlevel:
125
+ if pintofind != firstlevel [1 ]:
126
+ continue
127
+ # print ('firstlevel ' , i , firstlevel)
128
+ # n = pin node found
129
+ for m in n .childNodes :
130
+ j += 1
131
+ k = 0
132
+ if m .nodeType != Node .ELEMENT_NODE :
133
+ continue
134
+ for secondlevel in m .attributes .items ():
135
+ # print ('secondlevel ' , i, j, k , secondlevel)
136
+ k += 1
137
+ # if 'I2C1_SDA' in secondlevel:
138
+ if iptofind not in secondlevel :
139
+ continue
140
+ # m = IP node found
141
+ # print (i, j, m.attributes.items())
142
+ for p in m .childNodes :
143
+ # p node 'RemapBlock'
144
+ if (
145
+ p .nodeType == Node .ELEMENT_NODE
146
+ and p .hasChildNodes () is False
147
+ ):
148
+ if mygpioaf != "" :
149
+ mygpioaf += " "
150
+ mygpioaf += "AFIO_NONE"
151
+ else :
152
+ for s in p .childNodes :
153
+ if s .nodeType != Node .ELEMENT_NODE :
154
+ continue
155
+ # s node 'Specific parameter'
156
+ # print (i,j,k,p.attributes.items())
157
+ for myc in s .childNodes :
158
+ # DBG print (myc)
159
+ if myc .nodeType != Node .ELEMENT_NODE :
160
+ continue
161
+ # myc = AF value
162
+ for mygpioaflist in myc .childNodes :
163
+ if mygpioaf != "" :
164
+ mygpioaf += " "
165
+ mygpioaf += mygpioaflist .data .replace (
166
+ "__HAL_" , ""
167
+ ).replace ("_REMAP" , "" )
168
+ # print mygpioaf
169
169
if mygpioaf == "" :
170
170
mygpioaf = "AFIO_NONE"
171
171
return mygpioaf
0 commit comments