5 # PCB, interactive printed circuit board design
6 # Copyright (C) 2003 Dan McMahill
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 # $6: pad pitch (1/100 mm)
32 # $7: PCB pad width (1/100 mm)
33 # $8: Package pad length (1/100 mm)
34 # $9: Exposed paddle size, 0 for no exposed paddle (1/100 mm)
36 define(`PKG_GENERIC_QFN',
38 # number of pins on left/right sides (pin1 is upper pin on left side)
39 define(`LRPINS', `eval($4 / 4)')
40 # number of pins on top/bottom sides
41 define(`TBPINS', `eval(`$4' / 2 - LRPINS)')
42 # pin pitch (1/1000 mil)
43 define(`PITCH',`eval(`$6'*100000/254)')
44 # y-coordinate for upper pin on left/right sides (1/1000 mil)
45 define(`LRYMAX', `eval((LRPINS-1)*PITCH/2)')
46 # x-coordinate for right pin on top/bottom sides (1/1000 mil)
47 define(`TBXMAX', `eval((TBPINS-1)*PITCH/2)')
48 # total horizontal package width (1/1000 mil)
49 define(`LRWIDTHMM', `ifelse(0,`$5',`787',`eval($5)')')
50 define(`LRWIDTH', `ifelse(0,`$5',`787',`eval(`$5'*10000000/254)')')
51 # total vertical package width (1/1000 mil)
52 define(`TBWIDTH',`ifelse(0,`$5',`551',`eval(`$5'*10000000/254)')')
53 # how much pads extend beyond the package edge (1/1000 mil) (the 25 is 0.25 mm)
54 define(`EXTOUT', eval(25*100000/254))
55 # how much pads extend inward from the package pad edge (1/1000 mil)
56 define(`EXTIN', eval(5*100000/254))
57 # pad length/width (1/1000 mil)
58 define(`PADLENGTH', `eval(`$8'*100000/254)')
59 define(`PADWIDTH', `eval(`$7'*100000/254)')
61 define(`PADWIDTHMIL100', `eval(PADWIDTH/10)')
62 # min/max x coordinates for the pads on the left/right sides of the package (mil/100)
63 define(`LRXMAX',`eval((LRWIDTH/2 + EXTOUT - PADWIDTH/2)/10)')
64 define(`LRXMIN',`eval((LRWIDTH/2 -PADLENGTH - EXTIN + PADWIDTH/2)/10)')
65 # min/max y coordinates for the pads on the top/bottom sides of the package (mil/100)
66 define(`TBYMAX',`eval((TBWIDTH/2 + EXTOUT - PADWIDTH/2)/10)')
67 define(`TBYMIN',`eval((TBWIDTH/2 -PADLENGTH - EXTIN + PADWIDTH/2)/10)')
69 # silkscreen width (mils/100)
71 # how much the silk screen is moved away from the package (1/1000 mil)
72 define(`SILKEXT', `eval(EXTOUT + SILKW*10/2 + 5*1000)')
73 # upper right corner for silk screen (mil/100)
74 define(`SILKX', `eval((LRWIDTH/2 + SILKEXT )/10)')
75 define(`SILKY', `eval((TBWIDTH/2 + SILKEXT )/10)')
76 # refdes text size (mil/100)
77 define(`TEXTSIZE', 100)
78 # x,y coordinates for refdes label (mil/100)
79 define(`TEXTX', -SILKX)
80 define(`TEXTY', `eval(-SILKY - 1000 - TEXTSIZE/2)')
81 # square exposed paddle size (mil/100)
82 define(`EPSIZE', `eval(`$9'*10000/254)')
84 # pad clearance to polygons (1/100 mil)
85 define(`PADCLEAR', `2000')
87 # width of the pad solder mask relief (1/100 mil).
88 # grow by 1.5 mils on each side
89 define(`PADMASK', `eval(2*150 + PADWIDTHMIL100)')
91 # width of the paddle soldermask relief (1/100 mil)
92 # grow by 200 mils on each side
93 define(`EPMASK', `eval(2*200 + EPSIZE)')
95 # element_flags, description, pcb-name, value, mark_x, mark_y,
96 # text_x, text_y, text_direction, text_scale, text_flags
97 Element[0x00000000 "$1" "`$2'" "$3" 0 0 TEXTX TEXTY 0 TEXTSIZE 0x00000000]
101 # Pad[X1, Y1, X2, Y3, width, clearance,
102 # soldermask, "pin name", "pin number", flags]
107 forloop(`i', 1, LRPINS,
108 `define(`Y', `eval((-LRYMAX + PITCH*idx)/10)')'
109 `Pad[-LRXMAX Y -LRXMIN Y PADWIDTHMIL100 PADCLEAR PADMASK "CURPIN" "CURPIN" 0x00000100]'
110 `define(`CURPIN', incr(CURPIN))'
111 `define(`idx',incr(idx))'
116 forloop(`i', 1, TBPINS,
117 `define(`X', `eval((-TBXMAX + PITCH*idx)/10)')'
118 `Pad[X TBYMAX X TBYMIN PADWIDTHMIL100 PADCLEAR PADMASK "CURPIN" "CURPIN" 0x00000900]'
119 `define(`CURPIN', incr(CURPIN))'
120 `define(`idx',incr(idx))'
125 forloop(`i', 1, LRPINS,
126 `define(`Y', `eval(( LRYMAX - PITCH*idx)/10)')'
127 `Pad[LRXMAX Y LRXMIN Y PADWIDTHMIL100 PADCLEAR PADMASK "CURPIN" "CURPIN" 0x00000100]'
128 `define(`CURPIN', incr(CURPIN))'
129 `define(`idx',incr(idx))'
134 forloop(`i', 1, TBPINS,
135 `define(`X', `eval((TBXMAX - PITCH*idx)/10)')'
136 `Pad[X -TBYMAX X -TBYMIN PADWIDTHMIL100 PADCLEAR PADMASK "CURPIN" "CURPIN" 0x00000900]'
137 `define(`CURPIN', incr(CURPIN))'
138 `define(`idx',incr(idx))'
141 # Exposed paddle (if this is an exposed paddle part)
142 ifelse(1, eval(EPSIZE>0),
143 # Pad(X1, Y1, X2, Y3, width, clearance,
144 # soldermask, "pin name", "pin number", flags)
145 Pad[0 0 0 0 EPSIZE 0 EPMASK "CURPIN" "CURPIN" 0x00000100]
146 define(`CURPIN', incr(CURPIN))
149 # Silk screen around package
150 ElementLine[ SILKX SILKY SILKX -SILKY SILKW]
151 ElementLine[ SILKX -SILKY -SILKX -SILKY SILKW]
152 ElementLine[-SILKX -SILKY -SILKX SILKY SILKW]
153 ElementLine[-SILKX SILKY SILKX SILKY SILKW]
156 ElementLine[-SILKX -SILKY eval(-SILKX - 1500) eval(-SILKY - 1500) SILKW]
160 # -------------------------------------------------------------------
162 # The following macros take:
168 # $6: exposed paddle size (1/100 mm). 0 for no exposed paddle
171 # For an exposed paddle package, the paddle for an 'n' pin package is pin 'n+1'
174 define(`PKG_QFN_80', `PKG_GENERIC_QFN(`$1',`$2',`$3',`$4',`$5', `80',`42',`60', `$6')')
176 define(`PKG_QFN_65', `PKG_GENERIC_QFN(`$1',`$2',`$3',`$4',`$5', `65',`37',`60', `$6')')
177 # 0.50 mm pitch, 0.6 mm pad length
178 define(`PKG_QFN_50', `PKG_GENERIC_QFN(`$1',`$2',`$3',`$4',`$5', `50',`28',`60', `$6')')
179 # 0.50 mm pitch, 0.4 mm pad length
180 define(`PKG_QFN_50S',`PKG_GENERIC_QFN(`$1',`$2',`$3',`$4',`$5', `50',`28',`40', `$6')')
182 define(`PKG_QFN_40', `PKG_GENERIC_QFN(`$1',`$2',`$3',`$4',`$5', `40',`25',`60', `$6')')
191 # $6: pad pitch (1/100 mm)
192 # $7: PCB pad width (1/100 mm)
193 # $8: Package pad length (1/100 mm)
194 # $9: Exposed paddle size, 0 for no exposed paddle (1/100 mm)
195 # -------------------------------------------------------------------