def name2pin(name: str) ->int:
    """Convert pin name to number"""
    if not isinstance(name, str):
        raise TypeError('name must be a string')
    if len(name) < 3:
        raise ValueError('invalid name format')
    name = name.upper()
    if name[0] != 'P':
        raise ValueError('invalid name format')
    ports = 'ABCDEFGHIJKL'
    port_idx = ports.find(name[1])
    if port_idx < 0:
        raise ValueError('port name out of range')
    return int(port_idx * 32 + int(name[2:]))
