Date:2011-02-10 11:42:34 (13 years 1 month ago)
Author:Werner Almesberger
Commit:3e9f9613cb2cf55e715f0d5f02748f26789c2ef6
Message:atusb/fw2: added proper support for interrupt polling

- board.h (read_irq), board.c: return status of the RF IRQ
- board.h (PIN, PIN_1, PIN_2): macros to read port pins
- ep0.c (my_setup): make ATUSB_POLL_INT return the real interrupt
Files: atusb/fw2/board.c (2 diffs)
atusb/fw2/board.h (2 diffs)
atusb/fw2/ep0.c (1 diff)

Change Details

atusb/fw2/board.c
1#include <stdint.h>
2
13#include <avr/io.h>
24
35#define F_CPU 8000000UL
...... 
1820
1921    _delay_us(1);
2022}
23
24
25uint8_t read_irq(void)
26{
27    return PIN(IRQ_RF);
28}
atusb/fw2/board.h
11#ifndef BOARD_H
22#define BOARD_H
33
4#include <stdint.h>
5
6
47#define LED_PORT B
58#define LED_BIT 6
69#define nRST_RF_PORT C
...... 
2528#define CLR_2(p, b) PORT##p &= ~(1 << (b))
2629#define IN_2(p, b) DDR##p &= ~(1 << (b))
2730#define OUT_2(p, b) DDR##p |= 1 << (b)
31#define PIN_2(p, b) ((PIN##p >> (b)) & 1)
2832
2933#define SET_1(p, b) SET_2(p, b)
3034#define CLR_1(p, b) CLR_2(p, b)
3135#define IN_1(p, b) IN_2(p, b)
3236#define OUT_1(p, b) OUT_2(p, b)
37#define PIN_1(p, b) PIN_2(p, b)
3338
3439#define SET(n) SET_1(n##_PORT, n##_BIT)
3540#define CLR(n) CLR_1(n##_PORT, n##_BIT)
3641#define IN(n) IN_1(n##_PORT, n##_BIT)
3742#define OUT(n) OUT_1(n##_PORT, n##_BIT)
38
43#define PIN(n) PIN_1(n##_PORT, n##_BIT)
3944
4045void reset_rf(void);
46uint8_t read_irq(void);
4147
4248#endif /* !BOARD_H */
atusb/fw2/ep0.c
151151        debug("ATUSB_POLL_INT\n");
152152        if (setup->wLength < 1)
153153            return 0;
154        *buf = 0;//IRQ_RF;
154        *buf = read_irq();
155155        usb_send(&ep0, buf, 1, NULL, NULL);
156156        return 1;
157157

Archive Download the corresponding diff file



interactive