Horizon
footag.h
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 #ifndef FOOTAG_FOOTAG_H
21 #define FOOTAG_FOOTAG_H
22 
23 #include <stddef.h>
24 #include <stdbool.h>
25 #include <footag/footol.h>
26 
27 enum footag_data_type {
28  FOOTAG_DATA_NONE,
29  /* boolean */
30  FOOTAG_DATA_BOOL,
31  /* integers, no unit */
32  FOOTAG_DATA_INTEGER,
33  /* floating point numbers, no unit */
34  FOOTAG_DATA_FLOAT,
35  /* length in mm, represented as point numbers */
36  FOOTAG_DATA_LENGTH,
37  /* length in mm, with tolerance */
38  FOOTAG_DATA_TOL,
39  /* string/unsigned pairs */
40  FOOTAG_DATA_ENUM,
41  FOOTAG_DATA_BITMASK,
42  FOOTAG_DATA_NUM,
43 };
44 
45 struct footag_enum {
46  unsigned int val;
47  unsigned int num;
48  const char *const *strs;
49 };
50 
52  unsigned long val;
53  unsigned int num;
54  const char *const *strs;
55 };
56 
58  int val;
59  int step;
60  int min;
61  int max;
62 };
63 
64 union footag_data {
65  struct footag_integer i;
66  double l;
67  double f;
68  struct footol t;
69  struct footag_enum e;
70  struct footag_bitmask m;
71  bool b;
72 };
73 
74 struct footag_item {
75  enum footag_data_type type;
76  union footag_data data;
77 };
78 
79 enum {
80  FOOTAG_PARAM_DONE,
81  FOOTAG_PARAM_IGNORE,
82  FOOTAG_PARAM_TOPIC,
83 };
84 
85 struct footag_param {
86  int id;
87  const char *name;
88  const char *abbr;
89  struct footag_item item;
90 };
91 
92 #define FOOTAG_ANGLE_0 ((long) (0))
93 #define FOOTAG_ANGLE_90 ((long) (1 * (1<<16) / 4))
94 #define FOOTAG_ANGLE_180 ((long) (2 * (1<<16) / 4))
95 #define FOOTAG_ANGLE_270 ((long) (3 * (1<<16) / 4))
96 
97 enum footag_padstack {
98  FOOTAG_PADSTACK_SMD_RECT = 0,
99  FOOTAG_PADSTACK_SMD_RRECT,
100  FOOTAG_PADSTACK_SMD_CIRC,
101  FOOTAG_PADSTACK_SMD_OBLONG,
102  FOOTAG_PADSTACK_SMD_DSHAPE,
103  FOOTAG_PADSTACK_TH_ROUND,
104  FOOTAG_PADSTACK_TH_ROUND_RPAD,
105  FOOTAG_PADSTACK_NONE,
106  FOOTAG_PADSTACK_NUM,
107 };
108 
109 struct footag_pad {
110  enum footag_padstack stack;
111  double param;
112  double x, y;
113  double w, h;
114  double diam;
115  double holediam;
116  long angle;
117  /* must be NUL terminated */
118  char name[8];
119 };
120 
121 /* "rectangular limit" */
123  double minx, maxx;
124  double miny, maxy;
125 };
126 
127 static const struct footag_rlimit FOOTAG_RLIMIT_NONE = {
128  .minx = 0.0, .maxx = 0.0,
129  .miny = 0.0, .maxy = 0.0,
130 };
131 
132 struct footag_ref {
133  const char *doc;
134  const char *where;
135  const char *what;
136 };
137 
138 /* NOTE: It is up to the user to name the pads. He can sort them if in doubt. */
139 struct footag_spec {
140  struct footag_ref ref;
141  int npads;
142  struct footag_pad *pads;
143  struct footag_rlimit body;
144  struct footag_rlimit courtyard;
145 };
146 
147 /*
148  * Three different levels of something, which can be used where appropriate,
149  * for example in IPC-7351B and IPC-7251.
150  */
151 enum {
152  FOOTAG_LEVEL_0 = 0, FOOTAG_LEVEL_1, FOOTAG_LEVEL_2,
153  FOOTAG_LEVEL_A = 0, FOOTAG_LEVEL_B, FOOTAG_LEVEL_C,
154  /* most nominal least */
155  FOOTAG_LEVEL_M = 0, FOOTAG_LEVEL_N, FOOTAG_LEVEL_L,
156  FOOTAG_LEVEL_NUM = 3,
157 };
158 
159 enum footag_type {
160  FOOTAG_TYPE_CHIP,
161  FOOTAG_TYPE_CHIPARRAY,
162  FOOTAG_TYPE_LEDSC,
163  FOOTAG_TYPE_MELF,
164  FOOTAG_TYPE_MOLDED,
165  FOOTAG_TYPE_CAPAE,
166  FOOTAG_TYPE_SO,
167  FOOTAG_TYPE_SOD,
168  FOOTAG_TYPE_SODFL,
169  FOOTAG_TYPE_SOJ,
170  FOOTAG_TYPE_QFP,
171  FOOTAG_TYPE_SON,
172  FOOTAG_TYPE_QFN,
173  FOOTAG_TYPE_PSON,
174  FOOTAG_TYPE_PQFN,
175  FOOTAG_TYPE_BGA,
176  FOOTAG_TYPE_SOT223,
177  FOOTAG_TYPE_SOT23,
178  FOOTAG_TYPE_DIP,
179  FOOTAG_TYPE_SIP,
180  FOOTAG_TYPE_PGA,
181  FOOTAG_TYPE_NUM,
182 };
183 
185  enum footag_type type;
186  char *name;
187  char *brief;
188  char *desc;
189 };
190 
191 struct footag_ctx;
192 
193 const struct footag_typeinfo *footag_get_typeinfo(
194  enum footag_type footype
195 );
196 
197 struct footag_ctx *footag_open(
198  int footype
199 );
200 
201 int footag_close(
202  struct footag_ctx *ctx
203 );
204 
205 struct footag_param *footag_get_param(
206  struct footag_ctx *ctx
207 );
208 
209 const struct footag_spec *footag_get_spec(
210  struct footag_ctx *ctx
211 );
212 
213 const char *footag_hint(
214  struct footag_ctx *ctx,
215  const struct footag_param *p
216 );
217 
218 #endif
219 
footag_typeinfo
Definition: footag.h:184
footag_ref
Definition: footag.h:132
footag_rlimit
Definition: footag.h:122
footag_integer
Definition: footag.h:57
footag_enum
Definition: footag.h:45
footag_param
Definition: footag.h:85
footag_spec
Definition: footag.h:139
footag_pad
Definition: footag.h:109
footag_data
Definition: footag.h:64
footol
Definition: footol.h:27
footag_item
Definition: footag.h:74
footag_bitmask
Definition: footag.h:51
footag_ctx
Definition: priv.h:48