name: ATSAM4S
# there are too many alias and suffix
variations: LQFP-100, TFBGA-100, VFBGA-100, LQFP-64, QFN-64, SD16_WLCSP-64, S8_WLCSP-64, S4_WLCSP-64, LQFP-48, QFN-48
description: IC, MCU, Micro-Controller, Atmel, SAM4S series
datasheet: https://ww1.microchip.com/downloads/aemDocuments/documents/OTH/ProductDocuments/DataSheets/Atmel-11100-32-bitCortex-M4-Microcontroller-SAM4S_Datasheet.pdf

pinout@LQFP-100:
  PORTA:
    PA0/PGMEN0: 74
    PA1/PGMEN1: 72
    PA2/PGMEN2: 67
    PA3: 66
    PA4/PGMNCMD: 55
    PA5/PGMRDY: 53
    PA6/PGMNOE: 52
    PA7/XIN32/PGMNVALID: 49
    PA8/XOUT32/PGMM0: 48
    PA9/PGMM1: 46
    PA10/PGMM2: 44
    PA11/PGMM3: 42
    PA12/PGMD0: 41
    PA13/PGMD1: 33
    PA14/PGMD2: 31
    PA15/PGMD3: 30
    PA16/PGMD4: 28
    PA17/PGMD5/AD0: 12
    PA18/PGMD6/AD1: 14
    PA19/PGMD7/AD2: 18
    PA20/PGMD8/AD3: 24
    PA21/PGMD9/AD8: 15
    PA22/PGMD10/AD9: 20
    PA23/PGMD11: 22
    PA24/PGMD12: 34
    PA25/PGMD13: 38
    PA26/PGMD14: 39
    PA27/PGMD15: 57
    PA28: 59
    PA29: 63
    PA30: 64
    PA31: 81
  PORTB:
    PB0/AD4: 3
    PB1/AD5: 5
    PB2/AD6: 7
    PB3/AD7: 9
    TDI/PB4: 51
    TDO/TRACESWO/PB5: 76
    TMS/SWDIO/PB6: 79
    TCK/SWCLK/PB7: 83
    PB8/XOUT: 96
    PB9/PGMCK/XIN: 97
    DDM/PB10: 88
    DDP/PB11: 89
    ERASE/PB12: 87
    PB13/DAC0: 93
    PB14/DAC1: 99
  PORTC:
    PC0: 25
    PC1: 47
    PC2: 43
    PC3: 40
    PC4: 37
    PC5: 35
    PC6: 32
    PC7: 29
    PC8: 58
    PC9: 62
    PC10: 65
    PC11: 68
    PC12/AD12: 23
    PC13/AD10: 21
    PC14: 71
    PC15/AD11: 19
    PC16: 73
    PC17: 75
    PC18: 78
    PC19: 80
    PC20: 82
    PC21: 84
    PC22: 86
    PC23: 90
    PC24: 92
    PC25: 94
    PC26: 13
    PC27: 17
    PC28: 54
    PC29/AD13: 4
    PC30/AD14: 6
    PC31: 8
  CTRL:
    NRST: 60
    TST: 61
    JTAGSEL: 77
  POWER:
    VDDIN: 10
    VDDIO: 27,50,69,91,98
    VDDOUT: 11
    VDDCORE: 16,36,56,85
    VDDPLL: 100
    ADVREF: 1
  GROUND:
    GND: 2,26,45,70,95

pinout@TFBGA-100:
  PORTA:
    PA0/PGMEN0: C10
    PA1/PGMEN1: C8
    PA2/PGMEN2: D8
    PA3: E10
    PA4/PGMNCMD: G9
    PA5/PGMRDY: G10
    PA6/PGMNOE: H9
    PA7/XIN32/PGMNVALID: K10
    PA8/XOUT32/PGMM0: K9
    PA9/PGMM1: K8
    PA10/PGMM2: J7
    PA11/PGMM3: H7
    PA12/PGMD0: G7
    PA13/PGMD1: H5
    PA14/PGMD2: H4
    PA15/PGMD3: G3
    PA16/PGMD4: J3
    PA17/PGMD5/AD0: E1
    PA18/PGMD6/AD1: F1
    PA19/PGMD7/AD2: H1
    PA20/PGMD8/AD3: K4
    PA21/PGMD9/AD8: G1
    PA22/PGMD10/AD9: K1
    PA23/PGMD11: H2
    PA24/PGMD12: J5
    PA25/PGMD13: J6
    PA26/PGMD14: G6
    PA27/PGMD15: F6
    PA28: F8
    PA29: E7
    PA30: E8
    PA31: B7
  PORTB:
    PB0/AD4: D2
    PB1/AD5: A1
    PB2/AD6: C1
    PB3/AD7: D1
    TDI/PB4: H10
    TDO/TRACESWO/PB5: B10
    TMS/SWDIO/PB6: A9
    TCK/SWCLK/PB7: C6
    PB8/XOUT: A5
    PB9/PGMCK/XIN: A4
    DDM/PB10: A8
    DDP/PB11: A7
    ERASE/PB12: C5
    PB13/DAC0: A6
    PB14/DAC1: B4
  PORTC:
    PC0: J2
    PC1: H8
    PC2: K7
    PC3: K6
    PC4: H6
    PC5: K5
    PC6: J4
    PC7: H3
    PC8: F7
    PC9: F10
    PC10: E9
    PC11: D9
    PC12/AD12: K3
    PC13/AD10: K2
    PC14: D10
    PC15/AD11: J1
    PC16: C7
    PC17: C9
    PC18: B9
    PC19: B8
    PC20: B6
    PC21: B5
    PC22: D4
    PC23: C4
    PC24: D3
    PC25: C3
    PC26: F2
    PC27: G2
    PC28: G8
    PC29/AD13: A2
    PC30/AD14: B1
    PC31: E2
  CTRL:
    NRST: E6
    TST: F9
    JTAGSEL: A10
  POWER:
    VDDIN: E3
    VDDIO: A3,F5,J10
    VDDOUT: F3
    VDDCORE: D7,G4,G5,J9
    VDDPLL: C2
    ADVREF: B2
  GROUND:
    GND: D5,D6,E4,E5,F4,J8
    GNDANA: B3

pinout@VFBGA-100:
  PORTA:
    PA0/PGMEN0: C9
    PA1/PGMEN1: C8
    PA2/PGMEN2: E9
    PA3: E10
    PA4/PGMNCMD: F7
    PA5/PGMRDY: H10
    PA6/PGMNOE: H9
    PA7/XIN32/PGMNVALID: K10
    PA8/XOUT32/PGMM0: K9
    PA9/PGMM1: H7
    PA10/PGMM2: G6
    PA11/PGMM3: J7
    PA12/PGMD0: H6
    PA13/PGMD1: K4
    PA14/PGMD2: H4
    PA15/PGMD3: G4
    PA16/PGMD4: J3
    PA17/PGMD5/AD0: F3
    PA18/PGMD6/AD1: F2
    PA19/PGMD7/AD2: G2
    PA20/PGMD8/AD3: J1
    PA21/PGMD9/AD8: G3
    PA22/PGMD10/AD9: H2
    PA23/PGMD11: K1
    PA24/PGMD12: J5
    PA25/PGMD13: J6
    PA26/PGMD14: K5
    PA27/PGMD15: G10
    PA28: F8
    PA29: D6
    PA30: D7
    PA31: B8
  PORTB:
    PB0/AD4: C1
    PB1/AD5: D1
    PB2/AD6: E3
    PB3/AD7: E2
    TDI/PB4: J10
    TDO/TRACESWO/PB5: A10
    TMS/SWDIO/PB6: C7
    TCK/SWCLK/PB7: B7
    PB8/XOUT: A4
    PB9/PGMCK/XIN: A3
    DDM/PB10: A7
    DDP/PB11: A6
    ERASE/PB12: C4
    PB13/DAC0: B4
    PB14/DAC1: B3
  PORTC:
    PC0: K2
    PC1: G7
    PC2: K6
    PC3: G5
    PC4: H5
    PC5: D5
    PC6: J4
    PC7: K3
    PC8: F10
    PC9: C6
    PC10: E8
    PC11: D10
    PC12/AD12: J2
    PC13/AD10: H1
    PC14: D9
    PC15/AD11: G1
    PC16: C10
    PC17: B10
    PC18: B9
    PC19: A9
    PC20: A8
    PC21: B6
    PC22: D4
    PC23: B5
    PC24: C3
    PC25: B2
    PC26: F6
    PC27: H3
    PC28: G8
    PC29/AD13: C2
    PC30/AD14:  D2
    PC31: D3
  CTRL:
    NRST: G9
    TST: F9
    JTAGSEL: A5
  POWER:
    VDDIN: E1
    VDDIO: E7,K7,K8
    VDDOUT: F1
    VDDCORE: C5,H8,J8,J9
    VDDPLL: A2
    ADVREF: A1
  GROUND:
    GND: D8,E4,E5,E6,F4,F5
    GNDANA: B1

pinout@LQFP-64: &P64
  PORTA:
    PA0/PGMEN0: 48
    PA1/PGMEN1: 47
    PA2/PGMEN2: 44
    PA3: 43
    PA4/PGMNCMD: 36
    PA5/PGMRDY: 35
    PA6/PGMNOE: 34
    PA7/XIN32/PGMNVALID: 32
    PA8/XOUT32/PGMM0: 31
    PA9/PGMM1: 30
    PA10/PGMM2: 29
    PA11/PGMM3: 28
    PA12/PGMD0: 27
    PA13/PGMD1: 22
    PA14/PGMD2: 21
    PA15/PGMD3: 20
    PA16/PGMD4: 19
    PA17/PGMD5/AD0: 9
    PA18/PGMD6/AD1: 10
    PA19/PGMD7/AD2: 13
    PA20/PGMD8/AD3: 16
    PA21/PGMD9/AD8: 11
    PA22/PGMD10/AD9: 14
    PA23/PGMD11: 15
    PA24/PGMD12: 23
    PA25/PGMD13: 25
    PA26/PGMD14: 26
    PA27/PGMD15: 37
    PA28: 38
    PA29: 41
    PA30: 42
    PA31: 52
  PORTB:
    PB0/AD4: 3
    PB1/AD5: 4
    PB2/AD6: 5
    PB3/AD7: 6
    TDI/PB4: 33
    TDO/TRACESWO/PB5: 49
    TMS/SWDIO/PB6: 51
    TCK/SWCLK/PB7: 53
    XOUT/PB8: 61
    XIN/PGMCK/PB9: 62
    DDM/PB10: 56
    DDP/PB11: 57
    ERASE/PB12: 55
    PB13/DAC0: 59
    PB14/DAC1: 63
  CTRL:
    NRST: 39
    TST: 40
    JTAGSEL: 50
  POWER:
    VDDIN: 7
    VDDIO: 18,45,58
    VDDOUT: 8
    VDDCORE: 12,24,54
    VDDPLL: 64
    ADVREF: 1 
  GROUND:
    GND: 2,17,46,60

pinout@QFN-64: *P64

pinout@SD16_WLCSP-64: &SD16_WLCSP-64
  PORTA:
    PA0/PGMEN0: C3
    PA1/PGMEN1: C2
    PA2/PGMEN2: D4
    PA3: D2
    PA4/PGMNCMD: F3
    PA5/PGMRDY: G1
    PA6/PGMNOE: G2
    PA7/XIN32/PGMNVALID: H1
    PA8/XOUT32/PGMM0: H2
    PA9/PGMM1: G3
    PA10/PGMM2: H3
    PA11/PGMM3: G4
    PA12/PGMD0: H4
    PA13/PGMD1: D5
    PA14/PGMD2: G6
    PA15/PGMD3: H6
    PA16/PGMD4: F6
    PA17/PGMD5/AD0: D7
    PA18/PGMD6/AD1: E7
    PA19/PGMD7/AD2: G8
    PA20/PGMD8/AD3: G7
    PA21/PGMD9/AD8: D6
    PA22/PGMD10/AD9: F7
    PA23/PGMD11: E6
    PA24/PGMD12: H5
    PA25/PGMD13: E5
    PA26/PGMD14: F5
    PA27/PGMD15: F1
    PA28: E4
    PA29: E1
    PA30: D3
    PA31: A1
  PORTB:
    PB0/AD4: C8
    PB1/AD5: C7
    PB2/AD6: D8
    PB3/AD7: C6
    TDI/PB4: F4
    TDO/TRACESWO/PB5: B1
    TMS/SWDIO/PB6: B3
    TCK/SWCLK/PB7: A2
    XOUT/PB8: B7
    XIN/PGMCK/PB9: A7
    DDM/PB10: A4
    DDP/PB11: B4
    ERASE/PB12: C4
    PB13/DAC0: B5
    PB14/DAC1: A8
  CTRL:
    NRST: E3
    TST: E2
    JTAGSEL: B2
  POWER:
    VDDIN: E8
    VDDIO: A5,D1,H7
    VDDOUT: F8
    VDDCORE: A3,F2,G5
    VDDPLL: B6
    ADVREF: C5
  GROUND:
    GND: A6,B8,C1,H8

pinout@S8_WLCSP-64: *SD16_WLCSP-64

pinout@S4_WLCSP-64:
  PORTA:
    PA0/PGMEN0: C2
    PA1/PGMEN1: B1
    PA2/PGMEN2: D2
    PA3: E1
    PA4/PGMNCMD: G2
    PA5/PGMRDY: F3
    PA6/PGMNOE: F4
    PA7/XIN32/PGMNVALID: H2
    PA8/XOUT32/PGMM0: H3
    PA9/PGMM1: G3
    PA10/PGMM2: C5
    PA11/PGMM3: G4
    PA12/PGMD0: H4
    PA13/PGMD1: F5
    PA14/PGMD2: G6
    PA15/PGMD3: H6
    PA16/PGMD4: D7
    PA17/PGMD5/AD0: E7
    PA18/PGMD6/AD1: E6
    PA19/PGMD7/AD2: G8
    PA20/PGMD8/AD3: H8
    PA21/PGMD9/AD8: F7
    PA22/PGMD10/AD9: F6
    PA23/PGMD11: D6
    PA24/PGMD12: E5
    PA25/PGMD13: G5
    PA26/PGMD14: D5
    PA27/PGMD15: E4
    PA28: D3
    PA29: E3
    PA30: E2
    PA31: A2
  PORTB:
    PB0/AD4: C6
    PB1/AD5: C8
    PB2/AD6: C7
    PB3/AD7: D8
    TDI/PB4: H1
    TDO/TRACESWO/PB5: A1
    TMS/SWDIO/PB6: D4
    TCK/SWCLK/PB7: C3
    XOUT/PB8: A6
    XIN/PGMCK/PB9: A7
    DDM/PB10: B3
    DDP/PB11: B4
    ERASE/PB12: C4
    PB13/DAC0: B5
    PB14/DAC1: B7
  CTRL:
    NRST: F2
    TST: F1
    JTAGSEL: B2
  POWER:
    VDDIN: E8
    VDDIO: A4,D1,G7
    VDDOUT: F8
    VDDCORE: A3,G1,H5
    VDDPLL: B6
    ADVREF: A8
  GROUND:
    GND: A5,C1,H7
    GNDANA: B8

pinout@LQFP-48: &P48
  PORTA:
    PA0/PGMEN0: 36
    PA1/PGMEN1: 35
    PA2/PGMEN2: 32 
    PA3: 31
    PA4/PGMNCMD: 28
    PA5/PGMRDY: 27
    PA6/PGMNOE: 26
    PA7/XIN32/PGMNVALID: 24
    PA8/XOUT32/PGMM0: 23
    PA9/PGMM1: 22
    PA10/PGMM2: 21
    PA11/PGMM3: 20
    PA12/PGMD0: 19
    PA13/PGMD1: 17
    PA14/PGMD2: 16
    PA15/PGMD3: 15
    PA16/PGMD4: 14
    PA17/PGMD5/AD0: 9
    PA18/PGMD6/AD1: 10
    PA19/PGMD7/AD2: 11
    PA20/AD3: 12
  PORTB:
    PB0/AD4: 3
    PB1/AD5: 4
    PB2/AD6: 5
    PB3/AD7: 6
    TDI/PB4: 25
    TDO/TRACESWO/PB5: 37
    TMS/SWDIO/PB6: 39
    TCK/SWCLK/PB7: 40
    XOUT/PB8: 45
    XIN/PGMCK/PB9: 46
    DDM/PB10: 43
    DDP/PB11: 44
    ERASE/PB12: 42
  CTRL:
    NRST: 29
    TST: 30
    JTAGSEL: 38
  POWER:
    VDDIN: 7
    VDDIO: 13,33,47
    VDDOUT: 8
    VDDCORE: 18,41
    VDDPLL: 48
    ADVREF: 1
  GROUND:
    GND: 2,34

pinout@QFN-48: *P48

properties:
  in: NRST, TST, JTAGSEL
  bidir: PORTA, PORTB, PORTC
  power: POWER
  ground: GROUND
  inverted: NRST

schematic@100: &S100
  symbol: IC
  left: PORTA, CTRL
  right: PORTB, PORTC
  top: POWER
  bottom: GROUND

schematic@TFBGA-100: *S100

schematic@VFBGA-100: *S100

schematic@64: &S64
  symbol: IC
  left: PORTA
  right: PORTB, CTRL
  top: POWER
  bottom: GROUND

schematic@LQFP-64: *S64

schematic@QFN-64: *S64

schematic@SD16_WLCSP-64: *S64

schematic@S8_WLCSP-64: *S64

schematic@S4_WLCSP-64: *S64

schematic@LQFP-48: *S64

schematic@QFN-48: *S64

housing@LQFP-100:
  pattern: QFP
  bodyWidth: 14.0 # D1
  bodyLength: 14.0 # E1
  height: 1.6 # A
  leadWidth: 0.17-0.27 # b
  leadLength: 0.45-0.75 # L
  leadSpan: 16.0 # D
  pitch: 0.5 # e
  leadCount: 100
  rowCount: 25
  columnCount: 25

housing@TFBGA-100:
  pattern: BGA
  bodyWidth: 8.95-9.05 # E
  bodyLength: 8.95-9.05 # D
  height: 1.1 # A
  pitch: 0.8 # e
  rowCount: 10
  columnCount: 10
  leadDiameter: 0.35-0.45 # b
  leadCount: 100

housing@VFBGA-100:
  pattern: BGA
  bodyWidth: 6.9-7.1 # E
  bodyLength: 6.9-7.1 # D
  height: 1.0 # A
  pitch: 0.65 # e
  rowCount: 10
  columnCount: 10
  leadDiameter: 0.27-0.37 # b
  leadCount: 100

housing@LQFP-64:
  pattern: QFP
  bodyWidth: 10.0 # D1
  bodyLength: 10.0 # E1
  height: 1.6 # A
  leadWidth: 0.17-0.27 # b
  leadLength: 0.45-0.75 # L
  leadSpan: 12.0 # D
  pitch: 0.5 # e
  leadCount: 64
  rowCount: 16
  columnCount: 16

housing@QFN-64:
  pattern: QFN
  bodyWidth: 9.0 # D
  bodyLength: 9.0 # E
  height: 0.9 # A
  leadWidth: 0.23-0.29 # b
  leadLength: 0.35-0.45 # L
  leadSpan: 9.0 # D
  pitch: 0.5 # e
  leadCount: 64
  rowCount: 16
  columnCount: 16

housing@SD16_WLCSP-64:
  pattern: BGA
  bodyWidth: 4.423 # D
  bodyLength: 4.723 # E
  height: 0.455-0.533 # A
  pitch: 0.4 # e
  rowCount: 8
  columnCount: 8
  leadDiameter: 0.23-0.29 # b
  leadCount: 64

housing@S8_WLCSP-64:
  pattern: BGA
  bodyWidth: 4.424 # D
  bodyLength: 3.420 # E
  height: 0.455-0.533 # A
  pitch: 0.4 # e
  rowCount: 8
  columnCount: 8
  leadDiameter: 0.23-0.29 # b
  leadCount: 64

housing@S4_WLCSP-64:
  pattern: BGA
  bodyWidth: 3.323 # D
  bodyLength: 3.323 # E
  height: 0.455-0.533 # A
  pitch: 0.4 # e
  rowCount: 8
  columnCount: 8
  leadDiameter: 0.23-0.29 # b
  leadCount: 64

housing@LQFP-48:
  pattern: QFP
  bodyWidth: 7.0 # D1
  bodyLength: 7.0 # E1
  height: 1.6 # A
  leadWidth: 0.17-0.27 # b
  leadLength: 0.45-0.75 # L
  leadSpan: 9.0 # D
  pitch: 0.5 # e
  leadCount: 48
  rowCount: 12
  columnCount: 12

housing@QFN-48:
  pattern: QFN
  bodyWidth: 7.0 # D
  bodyLength: 7.0 # E
  height: 0.9 # A
  leadWidth: 0.18-0.23 # b
  leadLength: 0.35-0.45 # L
  leadSpan: 7.0 # D
  pitch: 0.5 # e
  leadCount: 48
  rowCount: 12
  columnCount: 12
