IEEE 802.15.4 subsystem
Sign in or create your account | Project List | Help
IEEE 802.15.4 subsystem Commit Details
Date: | 2010-11-11 12:48:08 (9 years 1 month ago) |
---|---|
Author: | Werner Almesberger |
Commit: | 84b61f35f23de6d3735851388d0da8540a08a949 |
Message: | The Great ATSPI Renaming, part 3: rename libatspi.a to libatrf.a - tools/lib/atspi.c: renamed to atrf.c - tools/lib/Makefile (OBJS): track above change - tools/Makefile.common (LDLIBS), tools/lib/Makefile (LIB): rename the whole library from libatspi to libatrf |
Files: |
tools/Makefile.common (1 diff) tools/lib/Makefile (2 diffs) tools/lib/atrf.c (1 diff) tools/lib/atspi.c (1 diff) |
Change Details
tools/Makefile.common | ||
---|---|---|
44 | 44 | |
45 | 45 | CFLAGS += $(CFLAGS_$(TARGET)) -I../../atusb/fw/include -I../include \ |
46 | 46 | $(MACROS_$(TARGET)) |
47 | LDLIBS = $(LDLIBS_$(TARGET)) -L../lib -latspi | |
47 | LDLIBS = $(LDLIBS_$(TARGET)) -L../lib -latrf | |
48 | 48 | OBJS += $(OBJS_$(TARGET)) |
tools/lib/Makefile | ||
---|---|---|
1 | 1 | # |
2 | # lib/Makefile - Build the ATSPI library | |
2 | # lib/Makefile - Build the ATRF library | |
3 | 3 | # |
4 | 4 | # Written 2010 by Werner Almesberger |
5 | 5 | # Copyright 2010 Werner Almesberger |
... | ... | |
11 | 11 | # |
12 | 12 | |
13 | 13 | |
14 | LIB = libatspi.a | |
14 | LIB = libatrf.a | |
15 | 15 | |
16 | 16 | include ../Makefile.common |
17 | 17 | |
18 | 18 | CFLAGS += -Wall -I$(F32XBASE)/include |
19 | 19 | OBJS_host = atusb.o $(F32XBASE)/lib/usb.o |
20 | 20 | OBJS_ben = atusd.o |
21 | OBJS = atspi.o misctxrx.o $(OBJS_$(TARGET)) | |
21 | OBJS = atrf.o misctxrx.o $(OBJS_$(TARGET)) | |
22 | 22 | |
23 | 23 | .PHONY: all clean spotless |
24 | 24 |
tools/lib/atrf.c | ||
---|---|---|
1 | /* | |
2 | * lib/atspi.c - ATSPI access functions library | |
3 | * | |
4 | * Written 2010 by Werner Almesberger | |
5 | * Copyright 2010 Werner Almesberger | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by | |
9 | * the Free Software Foundation; either version 2 of the License, or | |
10 | * (at your option) any later version. | |
11 | */ | |
12 | ||
13 | ||
14 | #include <stdlib.h> | |
15 | #include <stdio.h> | |
16 | ||
17 | #include "driver.h" | |
18 | #include "atspi.h" | |
19 | ||
20 | ||
21 | extern struct atspi_driver atusb_driver; | |
22 | extern struct atspi_driver atusd_driver; | |
23 | ||
24 | ||
25 | struct atspi_dsc { | |
26 | struct atspi_driver *driver; | |
27 | void *handle; | |
28 | }; | |
29 | ||
30 | ||
31 | void *atspi_usb_handle(struct atspi_dsc *dsc) | |
32 | { | |
33 | #ifdef HAVE_USB | |
34 | return dsc->handle; | |
35 | #else | |
36 | return NULL; | |
37 | #endif | |
38 | } | |
39 | ||
40 | ||
41 | int atspi_error(struct atspi_dsc *dsc) | |
42 | { | |
43 | return dsc->driver->error ? dsc->driver->error(dsc->handle) : 0; | |
44 | } | |
45 | ||
46 | ||
47 | int atspi_clear_error(struct atspi_dsc *dsc) | |
48 | { | |
49 | return dsc->driver->clear_error ? | |
50 | dsc->driver->clear_error(dsc->handle) : 0; | |
51 | } | |
52 | ||
53 | ||
54 | struct atspi_dsc *atspi_open(void) | |
55 | { | |
56 | struct atspi_dsc *dsc; | |
57 | struct atspi_driver *driver; | |
58 | void *handle; | |
59 | ||
60 | #ifdef HAVE_USB | |
61 | driver = &atusb_driver; | |
62 | #elif HAVE_USD | |
63 | driver = &atusd_driver; | |
64 | #else | |
65 | #error Need either HAVE_USB or HAVE_USD | |
66 | #endif | |
67 | handle = driver->open(); | |
68 | if (!handle) | |
69 | return NULL; | |
70 | dsc = malloc(sizeof(*dsc)); | |
71 | if (!dsc) { | |
72 | perror("malloc"); | |
73 | exit(1); | |
74 | } | |
75 | dsc->driver = driver; | |
76 | dsc->handle = handle; | |
77 | return dsc; | |
78 | } | |
79 | ||
80 | ||
81 | void atspi_close(struct atspi_dsc *dsc) | |
82 | { | |
83 | if (dsc->driver->close) | |
84 | dsc->driver->close(dsc->handle); | |
85 | free(dsc); | |
86 | } | |
87 | ||
88 | ||
89 | void atspi_reset(struct atspi_dsc *dsc) | |
90 | { | |
91 | if (dsc->driver->reset) | |
92 | dsc->driver->reset(dsc->handle); | |
93 | } | |
94 | ||
95 | ||
96 | void atspi_reset_rf(struct atspi_dsc *dsc) | |
97 | { | |
98 | dsc->driver->reset_rf(dsc->handle); | |
99 | } | |
100 | ||
101 | ||
102 | int atspi_test_mode(struct atspi_dsc *dsc) | |
103 | { | |
104 | if (!dsc->driver->test_mode) | |
105 | return 0; | |
106 | dsc->driver->test_mode(dsc->handle); | |
107 | return 1; | |
108 | } | |
109 | ||
110 | ||
111 | void atspi_reg_write(struct atspi_dsc *dsc, uint8_t reg, uint8_t value) | |
112 | { | |
113 | dsc->driver->reg_write(dsc->handle, reg, value); | |
114 | } | |
115 | ||
116 | ||
117 | uint8_t atspi_reg_read(struct atspi_dsc *dsc, uint8_t reg) | |
118 | { | |
119 | return dsc->driver->reg_read(dsc->handle, reg); | |
120 | } | |
121 | ||
122 | ||
123 | void atspi_buf_write(struct atspi_dsc *dsc, const void *buf, int size) | |
124 | { | |
125 | dsc->driver->buf_write(dsc->handle, buf, size); | |
126 | } | |
127 | ||
128 | ||
129 | int atspi_buf_read(struct atspi_dsc *dsc, void *buf, int size) | |
130 | { | |
131 | return dsc->driver->buf_read(dsc->handle, buf, size); | |
132 | } | |
133 | ||
134 | ||
135 | int atspi_interrupt(struct atspi_dsc *dsc) | |
136 | { | |
137 | return | |
138 | dsc->driver->interrupt ? dsc->driver->interrupt(dsc->handle) : 1; | |
139 | } |
tools/lib/atspi.c | ||
---|---|---|
1 | /* | |
2 | * lib/atspi.c - ATSPI access functions library | |
3 | * | |
4 | * Written 2010 by Werner Almesberger | |
5 | * Copyright 2010 Werner Almesberger | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by | |
9 | * the Free Software Foundation; either version 2 of the License, or | |
10 | * (at your option) any later version. | |
11 | */ | |
12 | ||
13 | ||
14 | #include <stdlib.h> | |
15 | #include <stdio.h> | |
16 | ||
17 | #include "driver.h" | |
18 | #include "atspi.h" | |
19 | ||
20 | ||
21 | extern struct atspi_driver atusb_driver; | |
22 | extern struct atspi_driver atusd_driver; | |
23 | ||
24 | ||
25 | struct atspi_dsc { | |
26 | struct atspi_driver *driver; | |
27 | void *handle; | |
28 | }; | |
29 | ||
30 | ||
31 | void *atspi_usb_handle(struct atspi_dsc *dsc) | |
32 | { | |
33 | #ifdef HAVE_USB | |
34 | return dsc->handle; | |
35 | #else | |
36 | return NULL; | |
37 | #endif | |
38 | } | |
39 | ||
40 | ||
41 | int atspi_error(struct atspi_dsc *dsc) | |
42 | { | |
43 | return dsc->driver->error ? dsc->driver->error(dsc->handle) : 0; | |
44 | } | |
45 | ||
46 | ||
47 | int atspi_clear_error(struct atspi_dsc *dsc) | |
48 | { | |
49 | return dsc->driver->clear_error ? | |
50 | dsc->driver->clear_error(dsc->handle) : 0; | |
51 | } | |
52 | ||
53 | ||
54 | struct atspi_dsc *atspi_open(void) | |
55 | { | |
56 | struct atspi_dsc *dsc; | |
57 | struct atspi_driver *driver; | |
58 | void *handle; | |
59 | ||
60 | #ifdef HAVE_USB | |
61 | driver = &atusb_driver; | |
62 | #elif HAVE_USD | |
63 | driver = &atusd_driver; | |
64 | #else | |
65 | #error Need either HAVE_USB or HAVE_USD | |
66 | #endif | |
67 | handle = driver->open(); | |
68 | if (!handle) | |
69 | return NULL; | |
70 | dsc = malloc(sizeof(*dsc)); | |
71 | if (!dsc) { | |
72 | perror("malloc"); | |
73 | exit(1); | |
74 | } | |
75 | dsc->driver = driver; | |
76 | dsc->handle = handle; | |
77 | return dsc; | |
78 | } | |
79 | ||
80 | ||
81 | void atspi_close(struct atspi_dsc *dsc) | |
82 | { | |
83 | if (dsc->driver->close) | |
84 | dsc->driver->close(dsc->handle); | |
85 | free(dsc); | |
86 | } | |
87 | ||
88 | ||
89 | void atspi_reset(struct atspi_dsc *dsc) | |
90 | { | |
91 | if (dsc->driver->reset) | |
92 | dsc->driver->reset(dsc->handle); | |
93 | } | |
94 | ||
95 | ||
96 | void atspi_reset_rf(struct atspi_dsc *dsc) | |
97 | { | |
98 | dsc->driver->reset_rf(dsc->handle); | |
99 | } | |
100 | ||
101 | ||
102 | int atspi_test_mode(struct atspi_dsc *dsc) | |
103 | { | |
104 | if (!dsc->driver->test_mode) | |
105 | return 0; | |
106 | dsc->driver->test_mode(dsc->handle); | |
107 | return 1; | |
108 | } | |
109 | ||
110 | ||
111 | void atspi_reg_write(struct atspi_dsc *dsc, uint8_t reg, uint8_t value) | |
112 | { | |
113 | dsc->driver->reg_write(dsc->handle, reg, value); | |
114 | } | |
115 | ||
116 | ||
117 | uint8_t atspi_reg_read(struct atspi_dsc *dsc, uint8_t reg) | |
118 | { | |
119 | return dsc->driver->reg_read(dsc->handle, reg); | |
120 | } | |
121 | ||
122 | ||
123 | void atspi_buf_write(struct atspi_dsc *dsc, const void *buf, int size) | |
124 | { | |
125 | dsc->driver->buf_write(dsc->handle, buf, size); | |
126 | } | |
127 | ||
128 | ||
129 | int atspi_buf_read(struct atspi_dsc *dsc, void *buf, int size) | |
130 | { | |
131 | return dsc->driver->buf_read(dsc->handle, buf, size); | |
132 | } | |
133 | ||
134 | ||
135 | int atspi_interrupt(struct atspi_dsc *dsc) | |
136 | { | |
137 | return | |
138 | dsc->driver->interrupt ? dsc->driver->interrupt(dsc->handle) : 1; | |
139 | } |