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_WCH_CH32V0 = SchLib(tool=SKIDL).add_parts(*[
        Part(**{ 'name':'CH32V003AxMx', 'dest':TEMPLATE, 'tool':SKIDL, 'aliases':Alias({'CH32V003AxMx'}), 'ref_prefix':'U', 'fplist':['Package_SO:SOP-16_3.9x9.9mm_P1.27mm'], 'footprint':'Package_SO:SOP-16_3.9x9.9mm_P1.27mm', 'keywords':'RISC-V WCH MCU microcontroller', 'description':'', 'datasheet':'https://www.wch-ic.com/products/CH32V003.html', 'search_text':'/usr/share/kicad/symbols/MCU_WCH_CH32V0.kicad_sym\nCH32V003AxMx\n\nRISC-V WCH MCU microcontroller', 'pins':[
            Pin(num='1',name='PC1',func=pin_types.BIDIR,unit=1),
            Pin(num='10',name='PD6',func=pin_types.BIDIR,unit=1),
            Pin(num='11',name='PD7',func=pin_types.BIDIR,unit=1),
            Pin(num='12',name='PA1',func=pin_types.BIDIR,unit=1),
            Pin(num='13',name='PA2',func=pin_types.BIDIR,unit=1),
            Pin(num='14',name='VSS',func=pin_types.PWRIN,unit=1),
            Pin(num='15',name='VDD',func=pin_types.PWRIN,unit=1),
            Pin(num='16',name='PC0',func=pin_types.BIDIR,unit=1),
            Pin(num='2',name='PC2',func=pin_types.BIDIR,unit=1),
            Pin(num='3',name='PC3',func=pin_types.BIDIR,unit=1),
            Pin(num='4',name='PC4',func=pin_types.BIDIR,unit=1),
            Pin(num='5',name='PC6',func=pin_types.BIDIR,unit=1),
            Pin(num='6',name='PC7',func=pin_types.BIDIR,unit=1),
            Pin(num='7',name='PD1',func=pin_types.BIDIR,unit=1),
            Pin(num='8',name='PD4',func=pin_types.BIDIR,unit=1),
            Pin(num='9',name='PD5',func=pin_types.BIDIR,unit=1)], 'unit_defs':[] }),
        Part(**{ 'name':'CH32V003FxPx', 'dest':TEMPLATE, 'tool':SKIDL, 'aliases':Alias({'CH32V003FxPx'}), 'ref_prefix':'U', 'fplist':['Package_SO:TSSOP-20_4.4x6.5mm_P0.65mm'], 'footprint':'Package_SO:TSSOP-20_4.4x6.5mm_P0.65mm', 'keywords':'microcontroller wch RISC-V', 'description':'', 'datasheet':'https://www.wch-ic.com/products/CH32V003.html', 'search_text':'/usr/share/kicad/symbols/MCU_WCH_CH32V0.kicad_sym\nCH32V003FxPx\n\nmicrocontroller wch RISC-V', 'pins':[
            Pin(num='1',name='PD4',func=pin_types.BIDIR,unit=1),
            Pin(num='10',name='PC0',func=pin_types.BIDIR,unit=1),
            Pin(num='11',name='PC1',func=pin_types.BIDIR,unit=1),
            Pin(num='12',name='PC2',func=pin_types.BIDIR,unit=1),
            Pin(num='13',name='PC3',func=pin_types.BIDIR,unit=1),
            Pin(num='14',name='PC4',func=pin_types.BIDIR,unit=1),
            Pin(num='15',name='PC5',func=pin_types.BIDIR,unit=1),
            Pin(num='16',name='PC6',func=pin_types.BIDIR,unit=1),
            Pin(num='17',name='PC7',func=pin_types.BIDIR,unit=1),
            Pin(num='18',name='PD1',func=pin_types.BIDIR,unit=1),
            Pin(num='19',name='PD2',func=pin_types.BIDIR,unit=1),
            Pin(num='2',name='PD5',func=pin_types.BIDIR,unit=1),
            Pin(num='20',name='PD3',func=pin_types.BIDIR,unit=1),
            Pin(num='3',name='PD6',func=pin_types.BIDIR,unit=1),
            Pin(num='4',name='PD7',func=pin_types.BIDIR,unit=1),
            Pin(num='5',name='PA1',func=pin_types.BIDIR,unit=1),
            Pin(num='6',name='PA2',func=pin_types.BIDIR,unit=1),
            Pin(num='7',name='VSS',func=pin_types.PWRIN,unit=1),
            Pin(num='8',name='PD0',func=pin_types.BIDIR,unit=1),
            Pin(num='9',name='VDD',func=pin_types.PWRIN,unit=1)], 'unit_defs':[] }),
        Part(**{ 'name':'CH32V003FxUx', 'dest':TEMPLATE, 'tool':SKIDL, 'aliases':Alias({'CH32V003FxUx'}), 'ref_prefix':'U', 'fplist':['Package_DFN_QFN:QFN-20-1EP_3x3mm_P0.4mm_EP1.65x1.65mm'], 'footprint':'Package_DFN_QFN:QFN-20-1EP_3x3mm_P0.4mm_EP1.65x1.65mm', 'keywords':'microcontroller wch RISC-V', 'description':'', 'datasheet':'https://www.wch-ic.com/products/CH32V003.html', 'search_text':'/usr/share/kicad/symbols/MCU_WCH_CH32V0.kicad_sym\nCH32V003FxUx\n\nmicrocontroller wch RISC-V', 'pins':[
            Pin(num='1',name='PD7',func=pin_types.BIDIR,unit=1),
            Pin(num='10',name='PC3',func=pin_types.BIDIR,unit=1),
            Pin(num='11',name='PC4',func=pin_types.BIDIR,unit=1),
            Pin(num='12',name='PC5',func=pin_types.BIDIR,unit=1),
            Pin(num='13',name='PC6',func=pin_types.BIDIR,unit=1),
            Pin(num='14',name='PC7',func=pin_types.BIDIR,unit=1),
            Pin(num='15',name='PD1',func=pin_types.BIDIR,unit=1),
            Pin(num='16',name='PD2',func=pin_types.BIDIR,unit=1),
            Pin(num='17',name='PD3',func=pin_types.BIDIR,unit=1),
            Pin(num='18',name='PD4',func=pin_types.BIDIR,unit=1),
            Pin(num='19',name='PD5',func=pin_types.BIDIR,unit=1),
            Pin(num='2',name='PA1',func=pin_types.BIDIR,unit=1),
            Pin(num='20',name='PD6',func=pin_types.BIDIR,unit=1),
            Pin(num='21',name='VSS',func=pin_types.PASSIVE,unit=1),
            Pin(num='3',name='PA2',func=pin_types.BIDIR,unit=1),
            Pin(num='4',name='VSS',func=pin_types.PWRIN,unit=1),
            Pin(num='5',name='PD0',func=pin_types.BIDIR,unit=1),
            Pin(num='6',name='VDD',func=pin_types.PWRIN,unit=1),
            Pin(num='7',name='PC0',func=pin_types.BIDIR,unit=1),
            Pin(num='8',name='PC1',func=pin_types.BIDIR,unit=1),
            Pin(num='9',name='PC2',func=pin_types.BIDIR,unit=1)], 'unit_defs':[] }),
        Part(**{ 'name':'CH32V003JxMx', 'dest':TEMPLATE, 'tool':SKIDL, 'aliases':Alias({'CH32V003JxMx'}), 'ref_prefix':'U', 'fplist':['Package_SO:SOP-8_3.9x4.9mm_P1.27mm'], 'footprint':'Package_SO:SOP-8_3.9x4.9mm_P1.27mm', 'keywords':'microcontroller wch RISC-V', 'description':'', 'datasheet':'https://www.wch-ic.com/products/CH32V003.html', 'search_text':'/usr/share/kicad/symbols/MCU_WCH_CH32V0.kicad_sym\nCH32V003JxMx\n\nmicrocontroller wch RISC-V', 'pins':[
            Pin(num='1',name='PD6/PA1',func=pin_types.BIDIR,unit=1),
            Pin(num='2',name='VSS',func=pin_types.PWRIN,unit=1),
            Pin(num='3',name='PA2',func=pin_types.BIDIR,unit=1),
            Pin(num='4',name='VDD',func=pin_types.PWRIN,unit=1),
            Pin(num='5',name='PC1',func=pin_types.BIDIR,unit=1),
            Pin(num='6',name='PC2',func=pin_types.BIDIR,unit=1),
            Pin(num='7',name='PC4',func=pin_types.BIDIR,unit=1),
            Pin(num='8',name='PD1/PD4/PD5',func=pin_types.BIDIR,unit=1)], 'unit_defs':[] })])