1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-11-17 21:42:28 +02:00

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
This commit is contained in:
Werner Almesberger 2011-02-10 07:42:34 -03:00
parent dcfa689936
commit 3e9f9613cb
3 changed files with 16 additions and 2 deletions

View File

@ -1,3 +1,5 @@
#include <stdint.h>
#include <avr/io.h>
#define F_CPU 8000000UL
@ -18,3 +20,9 @@ void reset_rf(void)
_delay_us(1);
}
uint8_t read_irq(void)
{
return PIN(IRQ_RF);
}

View File

@ -1,6 +1,9 @@
#ifndef BOARD_H
#define BOARD_H
#include <stdint.h>
#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 */

View File

@ -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;