From 3e9f9613cb2cf55e715f0d5f02748f26789c2ef6 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Thu, 10 Feb 2011 07:42:34 -0300 Subject: [PATCH] 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 --- atusb/fw2/board.c | 8 ++++++++ atusb/fw2/board.h | 8 +++++++- atusb/fw2/ep0.c | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/atusb/fw2/board.c b/atusb/fw2/board.c index d234546..fc69df9 100644 --- a/atusb/fw2/board.c +++ b/atusb/fw2/board.c @@ -1,3 +1,5 @@ +#include + #include #define F_CPU 8000000UL @@ -18,3 +20,9 @@ void reset_rf(void) _delay_us(1); } + + +uint8_t read_irq(void) +{ + return PIN(IRQ_RF); +} diff --git a/atusb/fw2/board.h b/atusb/fw2/board.h index 120eece..76bcdfb 100644 --- a/atusb/fw2/board.h +++ b/atusb/fw2/board.h @@ -1,6 +1,9 @@ #ifndef BOARD_H #define BOARD_H +#include + + #define LED_PORT B #define LED_BIT 6 #define nRST_RF_PORT C @@ -25,18 +28,21 @@ #define CLR_2(p, b) PORT##p &= ~(1 << (b)) #define IN_2(p, b) DDR##p &= ~(1 << (b)) #define OUT_2(p, b) DDR##p |= 1 << (b) +#define PIN_2(p, b) ((PIN##p >> (b)) & 1) #define SET_1(p, b) SET_2(p, b) #define CLR_1(p, b) CLR_2(p, b) #define IN_1(p, b) IN_2(p, b) #define OUT_1(p, b) OUT_2(p, b) +#define PIN_1(p, b) PIN_2(p, b) #define SET(n) SET_1(n##_PORT, n##_BIT) #define CLR(n) CLR_1(n##_PORT, n##_BIT) #define IN(n) IN_1(n##_PORT, n##_BIT) #define OUT(n) OUT_1(n##_PORT, n##_BIT) - +#define PIN(n) PIN_1(n##_PORT, n##_BIT) void reset_rf(void); +uint8_t read_irq(void); #endif /* !BOARD_H */ diff --git a/atusb/fw2/ep0.c b/atusb/fw2/ep0.c index 0def11a..aa0385b 100644 --- a/atusb/fw2/ep0.c +++ b/atusb/fw2/ep0.c @@ -151,7 +151,7 @@ static int my_setup(struct setup_request *setup) __reentrant debug("ATUSB_POLL_INT\n"); if (setup->wLength < 1) return 0; - *buf = 0;//IRQ_RF; + *buf = read_irq(); usb_send(&ep0, buf, 1, NULL, NULL); return 1;