@@ -23,18 +23,6 @@ def parse_port_pin(name_str):
2323 return (port , int (pin_str ))
2424
2525
26- def split_name_num (name_num ):
27- num = None
28- for num_idx in range (len (name_num ) - 1 , - 1 , - 1 ):
29- if not name_num [num_idx ].isdigit ():
30- name = name_num [0 :num_idx + 1 ]
31- num_str = name_num [num_idx + 1 :]
32- if len (num_str ) > 0 :
33- num = int (num_str )
34- break
35- return name , num
36-
37-
3826class Pin (object ):
3927 """Holds the information associated with a pin."""
4028
@@ -54,10 +42,9 @@ def set_is_board_pin(self):
5442 self .board_pin = True
5543
5644 def parse_adc (self , adc_str ):
57- if (adc_str [:3 ] != 'ADC ' ):
45+ if (adc_str [:3 ] != 'AIN ' ):
5846 return
59- (adc , channel ) = adc_str .split ('_IN' )
60- self .adc_channel = 'SAADC_CH_PSELP_PSELP_AnalogInput%d' % int (channel )
47+ self .adc_channel = 'SAADC_CH_PSELP_PSELP_AnalogInput%d' % int (adc_str [3 ])
6148
6249 def print (self ):
6350 print ('const pin_obj_t pin_{:s} = PIN({:s}, {:d}, {:d}, {:s});' .format (
@@ -94,20 +81,17 @@ def find_pin(self, port_num, pin_num):
9481 if pin .port == port_num and pin .pin == pin_num :
9582 return pin
9683
97- def parse_af_file (self , filename , pinname_col , af_col , af_col_end ):
84+ def parse_af_file (self , filename ):
9885 with open (filename , 'r' ) as csvfile :
9986 rows = csv .reader (csvfile )
10087 for row in rows :
10188 try :
102- (port_num , pin_num ) = parse_port_pin (row [pinname_col ])
89+ (port_num , pin_num ) = parse_port_pin (row [0 ])
10390 except :
10491 continue
10592 pin = Pin (port_num , pin_num )
106- for af_idx in range (af_col , len (row )):
107- if af_idx < af_col_end :
108- pin .parse_af (af_idx - af_col , row [af_idx ])
109- elif af_idx == af_col_end :
110- pin .parse_adc (row [af_idx ])
93+ if len (row ) > 1 :
94+ pin .parse_adc (row [1 ])
11195 self .cpu_pins .append (NamedPin (pin .cpu_pin_name (), pin ))
11296
11397 def parse_board_file (self , filename ):
@@ -121,8 +105,6 @@ def parse_board_file(self, filename):
121105 pin = self .find_pin (port_num , pin_num )
122106 if pin :
123107 pin .set_is_board_pin ()
124- if len (row ) == 3 :
125- pin .parse_adc (row [2 ])
126108 self .board_pins .append (NamedPin (row [0 ], pin ))
127109
128110 def print_named (self , label , named_pins ):
@@ -173,19 +155,7 @@ def main():
173155 "-a" , "--af" ,
174156 dest = "af_filename" ,
175157 help = "Specifies the alternate function file for the chip" ,
176- default = "nrf.csv"
177- )
178- parser .add_argument (
179- "--af-const" ,
180- dest = "af_const_filename" ,
181- help = "Specifies header file for alternate function constants." ,
182- default = "build/pins_af_const.h"
183- )
184- parser .add_argument (
185- "--af-py" ,
186- dest = "af_py_filename" ,
187- help = "Specifies the filename for the python alternate function mappings." ,
188- default = "build/pins_af.py"
158+ default = "nrf_af.csv"
189159 )
190160 parser .add_argument (
191161 "-b" , "--board" ,
@@ -218,7 +188,7 @@ def main():
218188 print ('//' )
219189 if args .af_filename :
220190 print ('// --af {:s}' .format (args .af_filename ))
221- pins .parse_af_file (args .af_filename , 1 , 2 , 2 )
191+ pins .parse_af_file (args .af_filename )
222192
223193 if args .board_filename :
224194 print ('// --board {:s}' .format (args .board_filename ))
0 commit comments