Date:2011-01-17 16:06:16 (8 years 9 months ago)
Author:Werner Almesberger
Commit:1cd079ee82b9805c90428a2bb0709ad1064d2cc1
Message:great atusd -> atben renaming: changed remaining references in tools/

- Makefile.common (MACROS_ben_jlime, MACROS_ben_openwrt), lib/atrf.c
(atrf_open): changed HAVE_USD to HAVE_BEN
- lib/atben.c: changed "uSD version" in title to "Ben 8:10 card version"
- lib/atrf.c, lib/atben.c: changed all occurrences of "atusd" to "atben"
Files: tools/Makefile.common (1 diff)
tools/lib/atben.c (13 diffs)
tools/lib/atrf.c (2 diffs)

Change Details

tools/Makefile.common
3333LDLIBS_ben_openwrt =
3434
3535MACROS_host = -DHAVE_USB
36MACROS_ben_jlime = -DHAVE_USD
37MACROS_ben_openwrt = -DHAVE_USD
36MACROS_ben_jlime = -DHAVE_BEN
37MACROS_ben_openwrt = -DHAVE_BEN
3838
3939CC_normal := $(CC_$(TARGET))
4040AR_normal := $(AR)
tools/lib/atben.c
11/*
2 * lib/atusd.c - ATRF access functions library (uSD version)
2 * lib/atben.c - ATRF access functions library (Ben 8:10 card version)
33 *
44 * Written 2010-2011 by Werner Almesberger
55 * Copyright 2010-2011 Werner Almesberger
...... 
6363#define PAGE_SIZE 4096
6464
6565
66struct atusd_dsc {
66struct atben_dsc {
6767    int fd;
6868    void *mem;
6969};
...... 
8282}
8383
8484
85static void atusd_cycle(struct atusd_dsc *dsc)
85static void atben_cycle(struct atben_dsc *dsc)
8686{
8787    /* stop the MMC bus clock */
8888    MSC_STRPCL = 1;
...... 
129129/* ----- Low-level SPI operations ------------------------------------------ */
130130
131131
132static void spi_begin(struct atusd_dsc *dsc)
132static void spi_begin(struct atben_dsc *dsc)
133133{
134134    PDDATC = nSEL;
135135}
136136
137137
138static void spi_end(struct atusd_dsc *dsc)
138static void spi_end(struct atben_dsc *dsc)
139139{
140140    PDDATS = nSEL;
141141}
142142
143143
144static void spi_send(struct atusd_dsc *dsc, uint8_t v)
144static void spi_send(struct atben_dsc *dsc, uint8_t v)
145145{
146146    uint8_t mask;
147147
...... 
156156}
157157
158158
159static uint8_t spi_recv(struct atusd_dsc *dsc)
159static uint8_t spi_recv(struct atben_dsc *dsc)
160160{
161161    uint8_t res = 0;
162162        uint8_t mask;
...... 
174174/* ----- Driver operations ------------------------------------------------- */
175175
176176
177static void atusd_reset_rf(void *handle)
177static void atben_reset_rf(void *handle)
178178{
179    struct atusd_dsc *dsc = handle;
179    struct atben_dsc *dsc = handle;
180180
181    atusd_cycle(dsc);
181    atben_cycle(dsc);
182182    wait_for_power();
183183}
184184
185185
186static void *atusd_open(void)
186static void *atben_open(void)
187187{
188    struct atusd_dsc *dsc;
188    struct atben_dsc *dsc;
189189
190190    dsc = malloc(sizeof(*dsc));
191191    if (!dsc) {
...... 
246246#endif
247247
248248    wait_for_power();
249    atusd_reset_rf(dsc);
249    atben_reset_rf(dsc);
250250
251251    return dsc;
252252}
253253
254254
255static void atusd_close(void *arg)
255static void atben_close(void *arg)
256256{
257    struct atusd_dsc *dsc = arg;
257    struct atben_dsc *dsc = arg;
258258
259259    /* stop the MMC bus clock */
260260    MSC_STRPCL = 1;
...... 
271271}
272272
273273
274static void atusd_reg_write(void *handle, uint8_t reg, uint8_t v)
274static void atben_reg_write(void *handle, uint8_t reg, uint8_t v)
275275{
276    struct atusd_dsc *dsc = handle;
276    struct atben_dsc *dsc = handle;
277277
278278    spi_begin(dsc);
279279    spi_send(dsc, AT86RF230_REG_WRITE | reg);
...... 
282282}
283283
284284
285static uint8_t atusd_reg_read(void *handle, uint8_t reg)
285static uint8_t atben_reg_read(void *handle, uint8_t reg)
286286{
287    struct atusd_dsc *dsc = handle;
287    struct atben_dsc *dsc = handle;
288288    uint8_t res;
289289
290290    spi_begin(dsc);
...... 
295295}
296296
297297
298static void atusd_buf_write(void *handle, const void *buf, int size)
298static void atben_buf_write(void *handle, const void *buf, int size)
299299{
300    struct atusd_dsc *dsc = handle;
300    struct atben_dsc *dsc = handle;
301301
302302    spi_begin(dsc);
303303    spi_send(dsc, AT86RF230_BUF_WRITE);
...... 
308308}
309309
310310
311static int atusd_buf_read(void *handle, void *buf, int size)
311static int atben_buf_read(void *handle, void *buf, int size)
312312{
313    struct atusd_dsc *dsc = handle;
313    struct atben_dsc *dsc = handle;
314314    uint8_t len, i;
315315
316316    spi_begin(dsc);
...... 
329329/* ----- RF interrupt ------------------------------------------------------ */
330330
331331
332static int atusd_interrupt(void *handle)
332static int atben_interrupt(void *handle)
333333{
334        struct atusd_dsc *dsc = handle;
334        struct atben_dsc *dsc = handle;
335335
336336    return !!(PDPIN & IRQ);
337337}
...... 
340340/* ----- Driver interface -------------------------------------------------- */
341341
342342
343struct atrf_driver atusd_driver = {
344    .name = "uSD",
345    .open = atusd_open,
346    .close = atusd_close,
343struct atrf_driver atben_driver = {
344    .name = "Ben",
345    .open = atben_open,
346    .close = atben_close,
347347    .reset = NULL,
348    .reset_rf = atusd_reset_rf,
348    .reset_rf = atben_reset_rf,
349349    .test_mode = NULL,
350    .reg_write = atusd_reg_write,
351    .reg_read = atusd_reg_read,
352    .buf_write = atusd_buf_write,
353    .buf_read = atusd_buf_read,
354    .interrupt = atusd_interrupt,
350    .reg_write = atben_reg_write,
351    .reg_read = atben_reg_read,
352    .buf_write = atben_buf_write,
353    .buf_read = atben_buf_read,
354    .interrupt = atben_interrupt,
355355};
tools/lib/atrf.c
2121
2222
2323extern struct atrf_driver atusb_driver;
24extern struct atrf_driver atusd_driver;
24extern struct atrf_driver atben_driver;
2525
2626
2727struct atrf_dsc {
...... 
6161
6262#ifdef HAVE_USB
6363    driver = &atusb_driver;
64#elif HAVE_USD
65    driver = &atusd_driver;
64#elif HAVE_BEN
65    driver = &atben_driver;
6666#else
67#error Need either HAVE_USB or HAVE_USD
67#error Need either HAVE_USB or HAVE_BEN
6868#endif
6969    handle = driver->open();
7070    if (!handle)

Archive Download the corresponding diff file



interactive