1 /*
2 * Copyright 2019 Martin Åberg
3 *
4 * This file is part of Footag.
5 *
6 * Footag is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, either version 3 of the License, or (at your option) any later
9 * version.
10 *
11 * Footag is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 * details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "priv.h"
21 #include <footag/ipc7351b.h>
22
23 static const struct footag_typeinfo info_molded = {
24 .type = FOOTAG_TYPE_MOLDED,
25 .name = "MOLDED",
26 .brief = "Molded capacitors, inductors, diodes, etc.",
27 };
28
29 static const struct footag_typeinfo info_melf = {
30 .type = FOOTAG_TYPE_MELF,
31 .name = "MELF",
32 .brief = "Metal electrode lead face",
33 };
34
35 /* "AVX C" / "EIA 2312" from some datasheet. */
36 static const struct footag_param temp[] = {
37 PARAM_TOPIC("Body"),
38 PARAM_T(BODY_L, "Length", "L", 6.00, 0.30),
39 PARAM_L(BODY_W, "Width", "W", 3.20),
40 #if 0
41 PARAM_T(BODY_H, "Height", "H", 2.50, 0.30),
42 #endif
43 PARAM_TOPIC("Lead"),
44 PARAM_T(LEAD_L, "Length", "A", 1.30, 0.30),
45 PARAM_T(LEAD_W, "Width", "W1", 2.20, 0.10),
46 PARAM_CALC_IPC7351B,
47 PARAM_PADSTACK_SMD_RECTS,
48 PARAM_TERM,
49 };
50
calc(struct footag_ctx * ctx)51 static int calc(
52 struct footag_ctx *ctx
53 )
54 {
55 struct footag_spec *const s = &ctx->spec;
56 struct ipcb_twospec spec;
57 const struct ipcb_comp comp = {
58 .l = GETID(ctx, BODY_L)->t,
59 .t = GETID(ctx, LEAD_L)->t,
60 .w = GETID(ctx, LEAD_W)->t,
61 };
62 struct ipcb_attr attr = {
63 .density = footag_get_density(&GETID(ctx, CALC_D)->e),
64 .f = GETID(ctx, CALC_F)->l,
65 .p = GETID(ctx, CALC_P)->l,
66 };
67 int ret;
68
69 if (ctx->op->info->type == FOOTAG_TYPE_MOLDED) {
70 ret = ipcb_get_molded(&spec, &comp, &attr);
71 } else if (ctx->op->info->type == FOOTAG_TYPE_MELF) {
72 ret = ipcb_get_melf(&spec, &comp, &attr);
73 } else {
74 ret = 1;
75 }
76 if (ret) { return ret; }
77
78 footag_gentwopin(
79 s->pads,
80 spec.land.dist,
81 spec.land.w, spec.land.h,
82 GETID(ctx, CALC_STACK)->e.val
83 );
84 s->body = footag_crlimit(
85 GETID(ctx, BODY_L)->t.nom,
86 GETID(ctx, BODY_W)->l
87 );
88 footag_ipc7351b_setrrectpads(&ctx->spec);
89 footag_snap(s, ROUNDOFF_TO_GRID[GETID(ctx, CALC_ROUND)->e.val]);
90 footag_setcourtyard(s, spec.cyexc);
91 footag_setref_ipc7351b(s, &spec.ref);
92
93 return 0;
94 }
95
96 const struct footag_op footag_op_molded = {
97 .size = sizeof (struct footag_ctx),
98 .init = footag_init_twopin,
99 .fini = footag_fini_default,
100 .calc = calc,
101 .info = &info_molded,
102 .temp = &temp[0],
103 };
104
105 const struct footag_op footag_op_melf = {
106 .size = sizeof (struct footag_ctx),
107 .init = footag_init_twopin,
108 .fini = footag_fini_default,
109 .calc = calc,
110 .info = &info_melf,
111 .temp = &temp[0],
112 };
113
114