summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kicad/delta.c1
-rw-r--r--kicad/lib-parse.c42
-rw-r--r--kicad/lib.h12
3 files changed, 52 insertions, 3 deletions
diff --git a/kicad/delta.c b/kicad/delta.c
index 874fd8f..d07915d 100644
--- a/kicad/delta.c
+++ b/kicad/delta.c
@@ -94,6 +94,7 @@ static bool comp_eq_obj(const struct lib_obj *a, const struct lib_obj *b)
a->u.pin.number_size == b->u.pin.number_size &&
a->u.pin.name_size == b->u.pin.name_size &&
a->u.pin.etype == b->u.pin.etype &&
+ a->u.pin.shape == b->u.pin.shape &&
!strcmp(a->u.pin.name, b->u.pin.name) &&
!strcmp(a->u.pin.number, b->u.pin.number);
default:
diff --git a/kicad/lib-parse.c b/kicad/lib-parse.c
index 2c1fe04..0d5d493 100644
--- a/kicad/lib-parse.c
+++ b/kicad/lib-parse.c
@@ -158,6 +158,37 @@ static void add_alias(struct comp *comp, const char *alias)
/* ----- Library parser ---------------------------------------------------- */
+static enum pin_shape decode_pin_shape(const char *s)
+{
+ int flags = 0;
+
+ if (*s == 'N') {
+ flags = pin_invisible;
+ s++;
+ }
+ if (!strcmp(s, ""))
+ return flags;
+ if (!strcmp(s, "I"))
+ return flags | pin_inverted;
+ if (!strcmp(s, "C"))
+ return flags | pin_clock;
+ if (!strcmp(s, "CI") || !strcmp(s, "IC"))
+ return flags | pin_clock | pin_inverted;
+ if (!strcmp(s, "L"))
+ return flags | pin_input_low;
+ if (!strcmp(s, "CL"))
+ return flags | pin_clock | pin_input_low;
+ if (!strcmp(s, "V"))
+ return flags | pin_output_low;;
+ if (!strcmp(s, "F"))
+ return flags | pin_falling_edge;
+ if (!strcmp(s, "X"))
+ return flags | pin_non_logic;
+ error("unrecognized pin shape \"%s\"", s);
+ return flags;
+}
+
+
static bool lib_parse_line(const struct file *file,
void *user, const char *line)
{
@@ -264,13 +295,20 @@ static bool lib_parse_line(const struct file *file,
obj->type = lib_obj_text;
return 1;
}
- if (sscanf(line, "X %ms %ms %d %d %d %c %d %d %u %u %c",
+ s = NULL;
+ if (sscanf(line, "X %ms %ms %d %d %d %c %d %d %u %u %c %ms",
&obj->u.pin.name, &obj->u.pin.number,
&obj->u.pin.x, &obj->u.pin.y, &obj->u.pin.length,
&obj->u.pin.orient,
&obj->u.pin.number_size, &obj->u.pin.name_size,
- &obj->unit, &obj->convert, &obj->u.pin.etype) == 11) {
+ &obj->unit, &obj->convert, &obj->u.pin.etype, &s) >= 11) {
obj->type = lib_obj_pin;
+ if (s) {
+ obj->u.pin.shape = decode_pin_shape(s);
+ free(s);
+ } else {
+ obj->u.pin.shape = 0;
+ }
return 1;
}
break;
diff --git a/kicad/lib.h b/kicad/lib.h
index c9b1a00..a6c48e9 100644
--- a/kicad/lib.h
+++ b/kicad/lib.h
@@ -20,6 +20,16 @@
#include "gfx/text.h"
+enum pin_shape {
+ pin_inverted = 1 << 0,
+ pin_clock = 1 << 1,
+ pin_input_low = 1 << 2,
+ pin_output_low = 1 << 3,
+ pin_falling_edge = 1 << 4,
+ pin_non_logic = 1 << 5,
+ pin_invisible = 1 << 6,
+};
+
enum lib_state {
lib_skip, /* before a definition */
lib_def, /* in definition */
@@ -82,7 +92,7 @@ struct lib_obj {
int number_size;
int name_size;
char etype;
- // @@@ shape
+ enum pin_shape shape;
} pin;
} u;
struct lib_obj *next;