2009-09-13 12:58:30 +03:00
|
|
|
/*
|
|
|
|
* layer.c - PCB layers on a pad
|
|
|
|
*
|
2012-07-19 01:52:19 +03:00
|
|
|
* Written 2009-2012 by Werner Almesberger
|
|
|
|
* Copyright 2009-2012 by Werner Almesberger
|
2009-09-13 12:58:30 +03:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
2009-09-13 14:11:03 +03:00
|
|
|
/*
|
|
|
|
* We don't reject solder paste pads that don't cover anything yet.
|
|
|
|
* That way, things can be constructed step by step without getting blue
|
|
|
|
* screens all the time.
|
|
|
|
*/
|
|
|
|
|
2009-09-13 12:58:30 +03:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2009-09-13 14:11:03 +03:00
|
|
|
#include "error.h"
|
|
|
|
#include "overlap.h"
|
|
|
|
#include "inst.h"
|
|
|
|
#include "obj.h"
|
2009-09-13 12:58:30 +03:00
|
|
|
#include "layer.h"
|
|
|
|
|
|
|
|
|
2009-09-13 14:11:03 +03:00
|
|
|
/*
|
|
|
|
* Shorthands for the layers we use in a general sense.
|
|
|
|
*/
|
|
|
|
|
2010-04-25 18:27:27 +03:00
|
|
|
#define LAYER_COPPER_TOP (1 << layer_top)
|
|
|
|
#define LAYER_PASTE_TOP (1 << layer_paste_top)
|
|
|
|
#define LAYER_MASK_TOP (1 << layer_mask_top)
|
|
|
|
#define LAYER_COPPER_BOTTOM (1 << layer_bottom)
|
|
|
|
#define LAYER_PASTE_BOTTOM (1 << layer_paste_bottom)
|
|
|
|
#define LAYER_MASK_BOTTOM (1 << layer_mask_bottom)
|
2009-09-13 14:11:03 +03:00
|
|
|
|
|
|
|
|
|
|
|
/* ----- Conversion between pad types and layer sets ----------------------- */
|
|
|
|
|
|
|
|
|
2009-09-13 12:58:30 +03:00
|
|
|
layer_type pad_type_to_layers(enum pad_type type)
|
|
|
|
{
|
|
|
|
layer_type layers = 0;
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case pt_normal:
|
2010-04-25 18:27:27 +03:00
|
|
|
layers = LAYER_PASTE_TOP;
|
2009-09-13 12:58:30 +03:00
|
|
|
/* fall through */
|
|
|
|
case pt_bare:
|
2010-04-25 18:27:27 +03:00
|
|
|
layers |= LAYER_COPPER_TOP | LAYER_MASK_TOP;
|
2009-09-13 12:58:30 +03:00
|
|
|
break;
|
2011-01-18 02:30:57 +02:00
|
|
|
case pt_trace:
|
|
|
|
layers |= LAYER_COPPER_TOP;
|
|
|
|
break;
|
2009-09-13 12:58:30 +03:00
|
|
|
case pt_paste:
|
2010-04-25 18:27:27 +03:00
|
|
|
layers = LAYER_PASTE_TOP;
|
2009-09-13 12:58:30 +03:00
|
|
|
break;
|
|
|
|
case pt_mask:
|
2010-04-25 18:27:27 +03:00
|
|
|
layers = LAYER_MASK_TOP;
|
2009-09-13 12:58:30 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
return layers;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
enum pad_type layers_to_pad_type(layer_type layers)
|
|
|
|
{
|
2010-04-25 18:27:27 +03:00
|
|
|
if (layers & LAYER_COPPER_TOP) {
|
|
|
|
if (layers & LAYER_PASTE_TOP)
|
2009-09-13 12:58:30 +03:00
|
|
|
return pt_normal;
|
2011-01-18 02:30:57 +02:00
|
|
|
if (layers & LAYER_MASK_TOP)
|
|
|
|
return pt_bare;
|
|
|
|
return pt_trace;
|
2009-09-13 12:58:30 +03:00
|
|
|
} else {
|
2010-04-25 18:27:27 +03:00
|
|
|
if (layers & LAYER_PASTE_TOP)
|
2009-09-13 12:58:30 +03:00
|
|
|
return pt_paste;
|
2010-04-25 18:27:27 +03:00
|
|
|
if (layers & LAYER_MASK_TOP)
|
2009-09-13 12:58:30 +03:00
|
|
|
return pt_mask;
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
2009-09-13 14:11:03 +03:00
|
|
|
|
|
|
|
|
2012-07-19 01:52:19 +03:00
|
|
|
const char *pad_type_name(enum pad_type type)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case pt_normal:
|
|
|
|
return "normal";
|
|
|
|
case pt_bare:
|
|
|
|
return "bare";
|
|
|
|
case pt_trace:
|
|
|
|
return "trace";
|
|
|
|
case pt_paste:
|
|
|
|
return "paste";
|
|
|
|
case pt_mask:
|
|
|
|
return "mask";
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-04-25 18:27:27 +03:00
|
|
|
/* ----- layers in mechanical holes ---------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
layer_type mech_hole_layers(void)
|
|
|
|
{
|
2011-03-25 01:42:47 +02:00
|
|
|
return LAYER_MASK_TOP | LAYER_MASK_BOTTOM;
|
2010-04-25 18:27:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-13 14:11:03 +03:00
|
|
|
/* ----- Refine layers after instantiation --------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
static int refine_overlapping(struct inst *copper, struct inst *other)
|
|
|
|
{
|
2010-04-25 18:27:27 +03:00
|
|
|
if (other->u.pad.layers & LAYER_PASTE_TOP) {
|
|
|
|
copper->u.pad.layers &= ~LAYER_PASTE_TOP;
|
2009-09-13 14:11:03 +03:00
|
|
|
if (!inside(other, copper)) {
|
|
|
|
fail("solder paste without copper underneath "
|
|
|
|
"(\"%s\" line %d, \"%s\" line %d)",
|
|
|
|
copper->u.pad.name, copper->obj->lineno,
|
|
|
|
other->u.pad.name, other->obj->lineno);
|
|
|
|
instantiation_error = other->obj;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2010-04-25 18:27:27 +03:00
|
|
|
if (other->u.pad.layers & LAYER_MASK_TOP)
|
|
|
|
copper->u.pad.layers &= ~LAYER_MASK_TOP;
|
2009-09-13 14:11:03 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Added relaxation of pad overlap checking. Not GUI-settable yet.
- README, fpd.l, fpd.y: added directives "allow touch" and "allow overlap" to
make overlap checking more permissive
- dump.c (dump_allow, dump): generate "allow" directive
- obj.h, obj.c (allow_overlap): added global variable for strictness of overlap
checking
- overlap.h, overlap.c (overlap, ...), layer.h, layer.c (refine_layers):
strictness of overlap checking is passed as an argument
- hole.c (check_through_hole), layer.h, layer.c (refine_copper), obj.c
(instantiate): updated callers of "overlap" to provide "allow" argument
git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5974 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-08-09 07:16:37 +03:00
|
|
|
static int refine_copper(const struct pkg *pkg_copper, struct inst *copper,
|
|
|
|
enum allow_overlap allow)
|
2009-09-13 14:11:03 +03:00
|
|
|
{
|
|
|
|
const struct pkg *pkg;
|
|
|
|
struct inst *other;
|
|
|
|
|
|
|
|
for (pkg = pkgs; pkg; pkg = pkg->next) {
|
|
|
|
/*
|
|
|
|
* Pads in distinct packages can happily coexist.
|
|
|
|
*/
|
|
|
|
if (pkg != pkgs && pkg_copper != pkgs && pkg_copper != pkg)
|
|
|
|
continue;
|
|
|
|
for (other = pkg->insts[ip_pad_copper]; other;
|
|
|
|
other = other->next)
|
Added relaxation of pad overlap checking. Not GUI-settable yet.
- README, fpd.l, fpd.y: added directives "allow touch" and "allow overlap" to
make overlap checking more permissive
- dump.c (dump_allow, dump): generate "allow" directive
- obj.h, obj.c (allow_overlap): added global variable for strictness of overlap
checking
- overlap.h, overlap.c (overlap, ...), layer.h, layer.c (refine_layers):
strictness of overlap checking is passed as an argument
- hole.c (check_through_hole), layer.h, layer.c (refine_copper), obj.c
(instantiate): updated callers of "overlap" to provide "allow" argument
git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5974 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-08-09 07:16:37 +03:00
|
|
|
if (copper != other && overlap(copper, other, allow)) {
|
2009-09-13 14:11:03 +03:00
|
|
|
fail("overlapping copper pads "
|
|
|
|
"(\"%s\" line %d, \"%s\" line %d)",
|
|
|
|
copper->u.pad.name, copper->obj->lineno,
|
|
|
|
other->u.pad.name, other->obj->lineno);
|
|
|
|
instantiation_error = copper->obj;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
for (other = pkg->insts[ip_pad_special]; other;
|
|
|
|
other = other->next)
|
Added relaxation of pad overlap checking. Not GUI-settable yet.
- README, fpd.l, fpd.y: added directives "allow touch" and "allow overlap" to
make overlap checking more permissive
- dump.c (dump_allow, dump): generate "allow" directive
- obj.h, obj.c (allow_overlap): added global variable for strictness of overlap
checking
- overlap.h, overlap.c (overlap, ...), layer.h, layer.c (refine_layers):
strictness of overlap checking is passed as an argument
- hole.c (check_through_hole), layer.h, layer.c (refine_copper), obj.c
(instantiate): updated callers of "overlap" to provide "allow" argument
git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5974 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-08-09 07:16:37 +03:00
|
|
|
if (overlap(copper, other, ao_none))
|
2009-09-13 14:11:03 +03:00
|
|
|
if (!refine_overlapping(copper, other))
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-04-25 18:27:27 +03:00
|
|
|
static void mirror_layers(layer_type *layers)
|
|
|
|
{
|
|
|
|
if (*layers & LAYER_COPPER_TOP)
|
|
|
|
*layers |= LAYER_COPPER_BOTTOM;
|
|
|
|
if (*layers & LAYER_PASTE_TOP)
|
|
|
|
*layers |= LAYER_PASTE_BOTTOM;
|
|
|
|
if (*layers & LAYER_MASK_TOP)
|
|
|
|
*layers |= LAYER_MASK_BOTTOM;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Added relaxation of pad overlap checking. Not GUI-settable yet.
- README, fpd.l, fpd.y: added directives "allow touch" and "allow overlap" to
make overlap checking more permissive
- dump.c (dump_allow, dump): generate "allow" directive
- obj.h, obj.c (allow_overlap): added global variable for strictness of overlap
checking
- overlap.h, overlap.c (overlap, ...), layer.h, layer.c (refine_layers):
strictness of overlap checking is passed as an argument
- hole.c (check_through_hole), layer.h, layer.c (refine_copper), obj.c
(instantiate): updated callers of "overlap" to provide "allow" argument
git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5974 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-08-09 07:16:37 +03:00
|
|
|
int refine_layers(enum allow_overlap allow)
|
2009-09-13 14:11:03 +03:00
|
|
|
{
|
|
|
|
const struct pkg *pkg;
|
|
|
|
struct inst *copper;
|
|
|
|
|
|
|
|
for (pkg = pkgs; pkg; pkg = pkg->next)
|
|
|
|
for (copper = pkg->insts[ip_pad_copper]; copper;
|
2010-04-25 18:27:27 +03:00
|
|
|
copper = copper->next) {
|
Added relaxation of pad overlap checking. Not GUI-settable yet.
- README, fpd.l, fpd.y: added directives "allow touch" and "allow overlap" to
make overlap checking more permissive
- dump.c (dump_allow, dump): generate "allow" directive
- obj.h, obj.c (allow_overlap): added global variable for strictness of overlap
checking
- overlap.h, overlap.c (overlap, ...), layer.h, layer.c (refine_layers):
strictness of overlap checking is passed as an argument
- hole.c (check_through_hole), layer.h, layer.c (refine_copper), obj.c
(instantiate): updated callers of "overlap" to provide "allow" argument
git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5974 99fdad57-331a-0410-800a-d7fa5415bdb3
2010-08-09 07:16:37 +03:00
|
|
|
if (!refine_copper(pkg, copper, allow))
|
2009-09-13 14:11:03 +03:00
|
|
|
return 0;
|
2010-04-25 18:27:27 +03:00
|
|
|
if (copper->u.pad.hole)
|
|
|
|
mirror_layers(&copper->u.pad.layers);
|
|
|
|
}
|
2009-09-13 14:11:03 +03:00
|
|
|
return 1;
|
|
|
|
}
|