<commit_before>#!/usr/bin/env python
"""Creates the pin file for the STM32F4xx."""

from __future__ import print_function

import argparse
import sys
import csv

SUPPORTED_FN = {
    'TIM'   : ['CH1',  'CH2',  'CH3',  'CH4',
               'CH1N', 'CH2N', 'CH3N', 'CH1_ETR', 'ETR', 'BKIN'],
    'I2C'   : ['SDA', 'SCL'],
    'I2S'   : ['CK', 'MCK', 'SD', 'WS', 'EXTSD'],
    'USART' : ['RX', 'TX', 'CTS', 'RTS', 'CK'],
    'UART'  : ['RX', 'TX', 'CTS', 'RTS'],
    'SPI'   : ['NSS', 'SCK', 'MISO', 'MOSI']
}

CONDITIONAL_VAR = {
    'I2C'   : 'MICROPY_HW_I2C{num}_SCL',
    'I2S'   : 'MICROPY_HW_ENABLE_I2S{num}',
    'SPI'   : 'MICROPY_HW_ENABLE_SPI{num}',
    'UART'  : 'MICROPY_HW_UART{num}_PORT',
    'UART5' : 'MICROPY_HW_UART5_TX_PORT',
    'USART' : 'MICROPY_HW_UART{num}_PORT',
}

def parse_port_pin(name_str):
    """Parses a string and returns a (port-num, pin-num) tuple."""
    if len(name_str) < 3:
        raise ValueError("Expecting pin name to be at least 3 charcters.")
    if name_str[0] != 'P':
        raise ValueError("Expecting pin name to start with P")
    if name_str[1] < 'A' or name_str[1] > 'J':
        raise ValueError("Expecting pin port to be between A and J")
    port = ord(name_str[1]) - ord('A')
    pin_str = name_str[2:]
    if not pin_str.isdigit():
        raise ValueError("Expecting numeric pin number.")
    return (port, int(pin_str))<commit_msg>stmhal: Fix make-pins.py to allow Port K.<commit_after>#!/usr/bin/env python
"""Creates the pin file for the STM32F4xx."""

from __future__ import print_function

import argparse
import sys
import csv

SUPPORTED_FN = {
    'TIM'   : ['CH1',  'CH2',  'CH3',  'CH4',
               'CH1N', 'CH2N', 'CH3N', 'CH1_ETR', 'ETR', 'BKIN'],
    'I2C'   : ['SDA', 'SCL'],
    'I2S'   : ['CK', 'MCK', 'SD', 'WS', 'EXTSD'],
    'USART' : ['RX', 'TX', 'CTS', 'RTS', 'CK'],
    'UART'  : ['RX', 'TX', 'CTS', 'RTS'],
    'SPI'   : ['NSS', 'SCK', 'MISO', 'MOSI']
}

CONDITIONAL_VAR = {
    'I2C'   : 'MICROPY_HW_I2C{num}_SCL',
    'I2S'   : 'MICROPY_HW_ENABLE_I2S{num}',
    'SPI'   : 'MICROPY_HW_ENABLE_SPI{num}',
    'UART'  : 'MICROPY_HW_UART{num}_PORT',
    'UART5' : 'MICROPY_HW_UART5_TX_PORT',
    'USART' : 'MICROPY_HW_UART{num}_PORT',
}

def parse_port_pin(name_str):
    """Parses a string and returns a (port-num, pin-num) tuple."""
    if len(name_str) < 3:
        raise ValueError("Expecting pin name to be at least 3 charcters.")
    if name_str[0] != 'P':
        raise ValueError("Expecting pin name to start with P")
    if name_str[1] < 'A' or name_str[1] > 'K':
        raise ValueError("Expecting pin port to be between A and K")
    port = ord(name_str[1]) - ord('A')
    pin_str = name_str[2:]
    if not pin_str.isdigit():
        raise ValueError("Expecting numeric pin number.")
    return (port, int(pin_str))
{'fraction_non_alphanumeric': 0.18945868945868946, 'fraction_numerical': 0.018518518518518517, 'mean_word_length': 3.2951070336391437, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2103585', 'n_tokens_mistral': 1191, 'n_tokens_neox': 1169, 'n_words': 277}