from collections import defaultdict
from skidl import Pin, Part, Alias, SchLib, SKIDL, TEMPLATE

from skidl.pin import pin_types

SKIDL_lib_version = '0.0.1'

MCU_Espressif = SchLib(tool=SKIDL).add_parts(*[
        Part(**{ 'name':'ESP32-C3', 'dest':TEMPLATE, 'tool':SKIDL, 'aliases':Alias({'ESP32-C3'}), 'ref_prefix':'U', 'fplist':['Package_DFN_QFN:QFN-32-1EP_5x5mm_P0.5mm_EP3.7x3.7mm'], 'footprint':'Package_DFN_QFN:QFN-32-1EP_5x5mm_P0.5mm_EP3.7x3.7mm', 'keywords':'WiFi BLE ESP32 Espressif', 'description':'', 'datasheet':'https://www.espressif.com/sites/default/files/documentation/esp32-c3_datasheet_en.pdf', 'search_text':'/usr/share/kicad/symbols/MCU_Espressif.kicad_sym\nESP32-C3\n\nWiFi BLE ESP32 Espressif', 'pins':[
            Pin(num='1',name='LNA_IN',func=pin_types.BIDIR,unit=1),
            Pin(num='10',name='MTDI',func=pin_types.BIDIR,unit=1),
            Pin(num='11',name='VDD3P3_RTC',func=pin_types.PWRIN,unit=1),
            Pin(num='12',name='MTCK',func=pin_types.BIDIR,unit=1),
            Pin(num='13',name='MTDO',func=pin_types.BIDIR,unit=1),
            Pin(num='14',name='GPIO8',func=pin_types.BIDIR,unit=1),
            Pin(num='15',name='GPIO9',func=pin_types.BIDIR,unit=1),
            Pin(num='16',name='GPIO10',func=pin_types.BIDIR,unit=1),
            Pin(num='17',name='VDD3P3_CPU',func=pin_types.PWRIN,unit=1),
            Pin(num='18',name='VDD_SPI',func=pin_types.PWROUT,unit=1),
            Pin(num='19',name='SPIHD',func=pin_types.BIDIR,unit=1),
            Pin(num='2',name='VDD3P3',func=pin_types.PWRIN,unit=1),
            Pin(num='20',name='SPIWP',func=pin_types.BIDIR,unit=1),
            Pin(num='21',name='SPICS0',func=pin_types.BIDIR,unit=1),
            Pin(num='22',name='SPICLK',func=pin_types.BIDIR,unit=1),
            Pin(num='23',name='SPID',func=pin_types.BIDIR,unit=1),
            Pin(num='24',name='SPIQ',func=pin_types.BIDIR,unit=1),
            Pin(num='25',name='GPIO18',func=pin_types.BIDIR,unit=1),
            Pin(num='26',name='GPIO19',func=pin_types.BIDIR,unit=1),
            Pin(num='27',name='U0RXD',func=pin_types.BIDIR,unit=1),
            Pin(num='28',name='U0TXD',func=pin_types.BIDIR,unit=1),
            Pin(num='29',name='XTAL_N',func=pin_types.BIDIR,unit=1),
            Pin(num='3',name='VDD3P3',func=pin_types.PASSIVE,unit=1),
            Pin(num='30',name='XTAL_P',func=pin_types.BIDIR,unit=1),
            Pin(num='31',name='VDDA',func=pin_types.PWRIN,unit=1),
            Pin(num='32',name='VDDA',func=pin_types.PASSIVE,unit=1),
            Pin(num='33',name='GND',func=pin_types.PWRIN,unit=1),
            Pin(num='4',name='XTAL_32K_P',func=pin_types.BIDIR,unit=1),
            Pin(num='5',name='XTAL_32K_N',func=pin_types.BIDIR,unit=1),
            Pin(num='6',name='GPIO2',func=pin_types.BIDIR,unit=1),
            Pin(num='7',name='CHIP_EN',func=pin_types.BIDIR,unit=1),
            Pin(num='8',name='GPIO3',func=pin_types.BIDIR,unit=1),
            Pin(num='9',name='MTMS',func=pin_types.BIDIR,unit=1)], 'unit_defs':[] }),
        Part(**{ 'name':'ESP32-PICO-D4', 'dest':TEMPLATE, 'tool':SKIDL, 'aliases':Alias({'ESP32-PICO-D4'}), 'ref_prefix':'U', 'fplist':['Package_DFN_QFN:QFN-48-1EP_7x7mm_P0.5mm_EP5.3x5.3mm'], 'footprint':'Package_DFN_QFN:QFN-48-1EP_7x7mm_P0.5mm_EP5.3x5.3mm', 'keywords':'RF Radio BT ESP ESP32 Espressif external antenna', 'description':'', 'datasheet':'https://www.espressif.com/sites/default/files/documentation/esp32-pico-d4_datasheet_en.pdf', 'search_text':'/usr/share/kicad/symbols/MCU_Espressif.kicad_sym\nESP32-PICO-D4\n\nRF Radio BT ESP ESP32 Espressif external antenna', 'pins':[
            Pin(num='1',name='VDDA',func=pin_types.PWRIN),
            Pin(num='10',name='IO34',func=pin_types.INPUT),
            Pin(num='11',name='IO35',func=pin_types.INPUT),
            Pin(num='12',name='IO32',func=pin_types.BIDIR),
            Pin(num='13',name='IO33',func=pin_types.BIDIR),
            Pin(num='14',name='IO25',func=pin_types.BIDIR),
            Pin(num='15',name='IO26',func=pin_types.BIDIR),
            Pin(num='16',name='IO27',func=pin_types.BIDIR),
            Pin(num='17',name='IO14',func=pin_types.BIDIR),
            Pin(num='18',name='IO12',func=pin_types.BIDIR),
            Pin(num='19',name='VDD3P3_RTC',func=pin_types.PWRIN),
            Pin(num='2',name='LNA_IN',func=pin_types.BIDIR),
            Pin(num='20',name='IO13',func=pin_types.BIDIR),
            Pin(num='21',name='IO15',func=pin_types.BIDIR),
            Pin(num='22',name='IO2',func=pin_types.BIDIR),
            Pin(num='23',name='IO0',func=pin_types.BIDIR),
            Pin(num='24',name='IO4',func=pin_types.BIDIR),
            Pin(num='25',name='IO16',func=pin_types.BIDIR),
            Pin(num='26',name='VDD_SDIO',func=pin_types.PWROUT),
            Pin(num='27',name='IO17',func=pin_types.BIDIR),
            Pin(num='28',name='SD2/IO9',func=pin_types.BIDIR),
            Pin(num='29',name='SD3/IO10',func=pin_types.BIDIR),
            Pin(num='3',name='VDDA3P3',func=pin_types.PWRIN),
            Pin(num='30',name='CMD',func=pin_types.BIDIR),
            Pin(num='31',name='CLK',func=pin_types.BIDIR),
            Pin(num='32',name='SD0',func=pin_types.BIDIR),
            Pin(num='33',name='SD1',func=pin_types.BIDIR),
            Pin(num='34',name='IO5',func=pin_types.BIDIR),
            Pin(num='35',name='IO18',func=pin_types.BIDIR),
            Pin(num='36',name='IO23',func=pin_types.BIDIR),
            Pin(num='37',name='VDD3P3_CPU',func=pin_types.PWRIN),
            Pin(num='38',name='IO19',func=pin_types.BIDIR),
            Pin(num='39',name='IO22',func=pin_types.BIDIR),
            Pin(num='4',name='VDDA3P3',func=pin_types.PASSIVE),
            Pin(num='40',name='U0RXD/IO3',func=pin_types.BIDIR),
            Pin(num='41',name='U0TXD/IO1',func=pin_types.BIDIR),
            Pin(num='42',name='IO21',func=pin_types.BIDIR),
            Pin(num='43',name='VDDA',func=pin_types.PASSIVE),
            Pin(num='44',name='XTAL_N_NC',func=pin_types.NOCONNECT),
            Pin(num='45',name='XTAL_P_NC',func=pin_types.NOCONNECT),
            Pin(num='46',name='VDDA',func=pin_types.PASSIVE),
            Pin(num='47',name='CAP2_NC',func=pin_types.NOCONNECT),
            Pin(num='48',name='CAP1_NC',func=pin_types.NOCONNECT),
            Pin(num='49',name='GND',func=pin_types.PWRIN),
            Pin(num='5',name='SENSOR_VP',func=pin_types.INPUT),
            Pin(num='6',name='SENSOR_CAPP',func=pin_types.INPUT),
            Pin(num='7',name='SENSOR_CAPN',func=pin_types.INPUT),
            Pin(num='8',name='SENSOR_VN',func=pin_types.INPUT),
            Pin(num='9',name='EN',func=pin_types.INPUT)], 'unit_defs':[] }),
        Part(**{ 'name':'ESP32-S2', 'dest':TEMPLATE, 'tool':SKIDL, 'aliases':Alias({'ESP32-S2'}), 'ref_prefix':'U', 'fplist':['Package_DFN_QFN:QFN-56-1EP_7x7mm_P0.4mm_EP4x4mm'], 'footprint':'Package_DFN_QFN:QFN-56-1EP_7x7mm_P0.4mm_EP4x4mm', 'keywords':'Microcontroller Wi-Fi BT ESP ESP32 Espressif', 'description':'', 'datasheet':'https://www.espressif.com/sites/default/files/documentation/esp32-s2_datasheet_en.pdf', 'search_text':'/usr/share/kicad/symbols/MCU_Espressif.kicad_sym\nESP32-S2\n\nMicrocontroller Wi-Fi BT ESP ESP32 Espressif', 'pins':[
            Pin(num='1',name='VDDA',func=pin_types.PWRIN,unit=1),
            Pin(num='10',name='GPIO5',func=pin_types.BIDIR,unit=1),
            Pin(num='11',name='GPIO6',func=pin_types.BIDIR,unit=1),
            Pin(num='12',name='GPIO7',func=pin_types.BIDIR,unit=1),
            Pin(num='13',name='GPIO8',func=pin_types.BIDIR,unit=1),
            Pin(num='14',name='GPIO9',func=pin_types.BIDIR,unit=1),
            Pin(num='15',name='GPIO10',func=pin_types.BIDIR,unit=1),
            Pin(num='16',name='GPIO11',func=pin_types.BIDIR,unit=1),
            Pin(num='17',name='GPIO12',func=pin_types.BIDIR,unit=1),
            Pin(num='18',name='GPIO13',func=pin_types.BIDIR,unit=1),
            Pin(num='19',name='GPIO14',func=pin_types.BIDIR,unit=1),
            Pin(num='2',name='LNA_IN',func=pin_types.BIDIR,unit=1),
            Pin(num='20',name='VDD3P3_RTC',func=pin_types.PWRIN,unit=1),
            Pin(num='21',name='XTAL_32K_P',func=pin_types.PASSIVE,unit=1),
            Pin(num='22',name='XTAL_32K_N',func=pin_types.PASSIVE,unit=1),
            Pin(num='23',name='DAC_1',func=pin_types.BIDIR,unit=1),
            Pin(num='24',name='DAC_2',func=pin_types.BIDIR,unit=1),
            Pin(num='25',name='GPIO19/USB_D-',func=pin_types.BIDIR,unit=1),
            Pin(num='26',name='GPIO20/USB_D+',func=pin_types.BIDIR,unit=1),
            Pin(num='27',name='VDD3P3_RTC_IO',func=pin_types.PWRIN,unit=1),
            Pin(num='28',name='GPIO21',func=pin_types.BIDIR,unit=1),
            Pin(num='29',name='SPICS1',func=pin_types.BIDIR,unit=1),
            Pin(num='3',name='VDD3P3',func=pin_types.PWRIN,unit=1),
            Pin(num='30',name='VDD_SPI',func=pin_types.PWROUT,unit=1),
            Pin(num='31',name='SPIHD',func=pin_types.BIDIR,unit=1),
            Pin(num='32',name='SPIWP',func=pin_types.BIDIR,unit=1),
            Pin(num='33',name='SPICS0',func=pin_types.BIDIR,unit=1),
            Pin(num='34',name='SPICLK',func=pin_types.BIDIR,unit=1),
            Pin(num='35',name='SPIQ',func=pin_types.BIDIR,unit=1),
            Pin(num='36',name='SPID',func=pin_types.BIDIR,unit=1),
            Pin(num='37',name='GPIO33',func=pin_types.BIDIR,unit=1),
            Pin(num='38',name='GPIO34',func=pin_types.BIDIR,unit=1),
            Pin(num='39',name='GPIO35',func=pin_types.BIDIR,unit=1),
            Pin(num='4',name='VDD3P3',func=pin_types.PASSIVE,unit=1),
            Pin(num='40',name='GPIO36',func=pin_types.BIDIR,unit=1),
            Pin(num='41',name='GPIO37',func=pin_types.BIDIR,unit=1),
            Pin(num='42',name='GPIO38',func=pin_types.BIDIR,unit=1),
            Pin(num='43',name='MTCK',func=pin_types.BIDIR,unit=1),
            Pin(num='44',name='MTD0',func=pin_types.BIDIR,unit=1),
            Pin(num='45',name='VDD3P3_CPU',func=pin_types.PWRIN,unit=1),
            Pin(num='46',name='MDTI',func=pin_types.BIDIR,unit=1),
            Pin(num='47',name='MTMS',func=pin_types.BIDIR,unit=1),
            Pin(num='48',name='U0TXD',func=pin_types.BIDIR,unit=1),
            Pin(num='49',name='U0RXD',func=pin_types.BIDIR,unit=1),
            Pin(num='5',name='GPIO0',func=pin_types.BIDIR,unit=1),
            Pin(num='50',name='GPIO45',func=pin_types.BIDIR,unit=1),
            Pin(num='51',name='VDDA',func=pin_types.PASSIVE,unit=1),
            Pin(num='52',name='XTAL_N',func=pin_types.OUTPUT,unit=1),
            Pin(num='53',name='XTAL_P',func=pin_types.INPUT,unit=1),
            Pin(num='54',name='VDDA',func=pin_types.PASSIVE,unit=1),
            Pin(num='55',name='GPIO46',func=pin_types.INPUT,unit=1),
            Pin(num='56',name='CHIP_PU',func=pin_types.INPUT,unit=1),
            Pin(num='57',name='GND',func=pin_types.PWRIN,unit=1),
            Pin(num='6',name='GPIO1',func=pin_types.BIDIR,unit=1),
            Pin(num='7',name='GPIO2',func=pin_types.BIDIR,unit=1),
            Pin(num='8',name='GPIO3',func=pin_types.BIDIR,unit=1),
            Pin(num='9',name='GPIO4',func=pin_types.BIDIR,unit=1)], 'unit_defs':[] }),
        Part(**{ 'name':'ESP32-S3', 'dest':TEMPLATE, 'tool':SKIDL, 'aliases':Alias({'ESP32-S3'}), 'ref_prefix':'U', 'fplist':['Package_DFN_QFN:QFN-56-1EP_7x7mm_P0.4mm_EP4x4mm'], 'footprint':'Package_DFN_QFN:QFN-56-1EP_7x7mm_P0.4mm_EP4x4mm', 'keywords':'Microcontroller Wi-Fi BT ESP ESP32 Espressif', 'description':'', 'datasheet':'https://www.espressif.com/sites/default/files/documentation/esp32-s3_datasheet_en.pdf', 'search_text':'/usr/share/kicad/symbols/MCU_Espressif.kicad_sym\nESP32-S3\n\nMicrocontroller Wi-Fi BT ESP ESP32 Espressif', 'pins':[
            Pin(num='36',name='SPICLK_N',func=pin_types.BIDIR,unit=1),
            Pin(num='45',name='MTDO',func=pin_types.BIDIR,unit=1),
            Pin(num='51',name='GPIO45',func=pin_types.BIDIR,unit=1),
            Pin(num='56',name='VDDA',func=pin_types.PASSIVE,unit=1),
            Pin(num='1',name='LNA_IN',func=pin_types.BIDIR,unit=1),
            Pin(num='10',name='GPIO5',func=pin_types.BIDIR,unit=1),
            Pin(num='11',name='GPIO6',func=pin_types.BIDIR,unit=1),
            Pin(num='12',name='GPIO7',func=pin_types.BIDIR,unit=1),
            Pin(num='13',name='GPIO8',func=pin_types.BIDIR,unit=1),
            Pin(num='14',name='GPIO9',func=pin_types.BIDIR,unit=1),
            Pin(num='15',name='GPIO10',func=pin_types.BIDIR,unit=1),
            Pin(num='16',name='GPIO11',func=pin_types.BIDIR,unit=1),
            Pin(num='17',name='GPIO12',func=pin_types.BIDIR,unit=1),
            Pin(num='18',name='GPIO13',func=pin_types.BIDIR,unit=1),
            Pin(num='19',name='GPIO14',func=pin_types.BIDIR,unit=1),
            Pin(num='2',name='VDD3P3',func=pin_types.PWRIN,unit=1),
            Pin(num='20',name='VDD3P3_RTC',func=pin_types.PWRIN,unit=1),
            Pin(num='21',name='XTAL_32K_P',func=pin_types.PASSIVE,unit=1),
            Pin(num='22',name='XTAL_32K_N',func=pin_types.PASSIVE,unit=1),
            Pin(num='23',name='GPIO17',func=pin_types.BIDIR,unit=1),
            Pin(num='24',name='GPIO18',func=pin_types.BIDIR,unit=1),
            Pin(num='25',name='GPIO19/USB_D-',func=pin_types.BIDIR,unit=1),
            Pin(num='26',name='GPIO20/USB_D+',func=pin_types.BIDIR,unit=1),
            Pin(num='27',name='GPIO21',func=pin_types.BIDIR,unit=1),
            Pin(num='28',name='SPICS1',func=pin_types.BIDIR,unit=1),
            Pin(num='29',name='VDD_SPI',func=pin_types.PWRIN,unit=1),
            Pin(num='3',name='VDD3P3',func=pin_types.PASSIVE,unit=1),
            Pin(num='30',name='SPIHD',func=pin_types.BIDIR,unit=1),
            Pin(num='31',name='SPIWP',func=pin_types.BIDIR,unit=1),
            Pin(num='32',name='SPICS0',func=pin_types.BIDIR,unit=1),
            Pin(num='33',name='SPICLK',func=pin_types.BIDIR,unit=1),
            Pin(num='34',name='SPIQ',func=pin_types.BIDIR,unit=1),
            Pin(num='35',name='SPID',func=pin_types.BIDIR,unit=1),
            Pin(num='37',name='SPICLK_P',func=pin_types.BIDIR,unit=1),
            Pin(num='38',name='GPIO33',func=pin_types.BIDIR,unit=1),
            Pin(num='39',name='GPIO34',func=pin_types.BIDIR,unit=1),
            Pin(num='4',name='CHIP_PU',func=pin_types.INPUT,unit=1),
            Pin(num='40',name='GPIO35',func=pin_types.BIDIR,unit=1),
            Pin(num='41',name='GPIO36',func=pin_types.BIDIR,unit=1),
            Pin(num='42',name='GPIO37',func=pin_types.BIDIR,unit=1),
            Pin(num='43',name='GPIO38',func=pin_types.BIDIR,unit=1),
            Pin(num='44',name='MTCK',func=pin_types.BIDIR,unit=1),
            Pin(num='46',name='VDD3P3_CPU',func=pin_types.PWRIN,unit=1),
            Pin(num='47',name='MTDI',func=pin_types.BIDIR,unit=1),
            Pin(num='48',name='MTMS',func=pin_types.BIDIR,unit=1),
            Pin(num='49',name='U0TXD',func=pin_types.BIDIR,unit=1),
            Pin(num='5',name='GPIO0',func=pin_types.BIDIR,unit=1),
            Pin(num='50',name='U0RXD',func=pin_types.BIDIR,unit=1),
            Pin(num='52',name='GPIO46',func=pin_types.BIDIR,unit=1),
            Pin(num='53',name='XTAL_N',func=pin_types.OUTPUT,unit=1),
            Pin(num='54',name='XTAL_P',func=pin_types.INPUT,unit=1),
            Pin(num='55',name='VDDA',func=pin_types.PWRIN,unit=1),
            Pin(num='57',name='GND',func=pin_types.PWRIN,unit=1),
            Pin(num='6',name='GPIO1',func=pin_types.BIDIR,unit=1),
            Pin(num='7',name='GPIO2',func=pin_types.BIDIR,unit=1),
            Pin(num='8',name='GPIO3',func=pin_types.BIDIR,unit=1),
            Pin(num='9',name='GPIO4',func=pin_types.BIDIR,unit=1)], 'unit_defs':[] }),
        Part(**{ 'name':'ESP8266EX', 'dest':TEMPLATE, 'tool':SKIDL, 'aliases':Alias({'ESP8266EX'}), 'ref_prefix':'U', 'fplist':['Package_DFN_QFN:QFN-32-1EP_5x5mm_P0.5mm_EP3.45x3.45mm'], 'footprint':'Package_DFN_QFN:QFN-32-1EP_5x5mm_P0.5mm_EP3.45x3.45mm', 'keywords':'wifi soc', 'description':'', 'datasheet':'http://espressif.com/sites/default/files/documentation/0a-esp8266ex_datasheet_en.pdf', 'search_text':'/usr/share/kicad/symbols/MCU_Espressif.kicad_sym\nESP8266EX\n\nwifi soc', 'pins':[
            Pin(num='1',name='VDDA',func=pin_types.PWRIN,unit=1),
            Pin(num='10',name='MTDI',func=pin_types.BIDIR,unit=1),
            Pin(num='11',name='VDDPST',func=pin_types.PWRIN,unit=1),
            Pin(num='12',name='MTCK',func=pin_types.BIDIR,unit=1),
            Pin(num='13',name='MTDO',func=pin_types.BIDIR,unit=1),
            Pin(num='14',name='GPIO2',func=pin_types.BIDIR,unit=1),
            Pin(num='15',name='GPIO0',func=pin_types.BIDIR,unit=1),
            Pin(num='16',name='GPIO4',func=pin_types.BIDIR,unit=1),
            Pin(num='17',name='VDDPST',func=pin_types.PWRIN,unit=1),
            Pin(num='18',name='SDIO_DATA_2',func=pin_types.BIDIR,unit=1),
            Pin(num='19',name='SDIO_DATA_3',func=pin_types.BIDIR,unit=1),
            Pin(num='2',name='LNA',func=pin_types.BIDIR,unit=1),
            Pin(num='20',name='SDIO_CMD',func=pin_types.BIDIR,unit=1),
            Pin(num='21',name='SDIO_CLK',func=pin_types.BIDIR,unit=1),
            Pin(num='22',name='SDIO_DATA_0',func=pin_types.BIDIR,unit=1),
            Pin(num='23',name='SDIO_DATA_1',func=pin_types.BIDIR,unit=1),
            Pin(num='24',name='GPIO5',func=pin_types.BIDIR,unit=1),
            Pin(num='25',name='U0RXD',func=pin_types.BIDIR,unit=1),
            Pin(num='26',name='U0TXD',func=pin_types.BIDIR,unit=1),
            Pin(num='27',name='XTAL_OUT',func=pin_types.BIDIR,unit=1),
            Pin(num='28',name='XTAL_IN',func=pin_types.BIDIR,unit=1),
            Pin(num='29',name='VDDD',func=pin_types.PWRIN,unit=1),
            Pin(num='3',name='VDD3P3',func=pin_types.PWRIN,unit=1),
            Pin(num='30',name='VDDA',func=pin_types.PWRIN,unit=1),
            Pin(num='31',name='RES12K',func=pin_types.INPUT,unit=1),
            Pin(num='32',name='~{EXT_RSTB}',func=pin_types.INPUT,unit=1),
            Pin(num='33',name='GND',func=pin_types.PWRIN,unit=1),
            Pin(num='4',name='VDD3P3',func=pin_types.PWRIN,unit=1),
            Pin(num='5',name='VDD_RTC',func=pin_types.PWRIN,unit=1),
            Pin(num='6',name='TOUT',func=pin_types.INPUT,unit=1),
            Pin(num='7',name='CHIP_PU',func=pin_types.INPUT,unit=1),
            Pin(num='8',name='XPD_DCDC',func=pin_types.BIDIR,unit=1),
            Pin(num='9',name='MTMS',func=pin_types.BIDIR,unit=1)], 'unit_defs':[] })])