1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-12-27 21:24:37 +02:00

atusb/fw/: added reporting of RF interrupts via bulk EP1

- board.h (board_app_init), board_app.c (board_app_init): new function
  for application-specific board initialization
- atusb.c (main): call board_app_init
- board_app.c (INT0_vect): on RF interrupt, read REG_IRQ_STATUS and
  send the status byte on EP1
- board_app.c (board_app_init): set up interrupt on rising edge of
  INT0 (INT_RF)
- descr.c (config_descriptor): added EP1 as bulk IN
This commit is contained in:
Werner Almesberger 2011-06-20 15:49:33 -03:00
parent 244e449131
commit 0120f62242
4 changed files with 31 additions and 6 deletions

View File

@ -28,6 +28,7 @@
int main(void)
{
board_init();
board_app_init();
reset_rf();
user_get_descriptor = sernum_get_descr;

View File

@ -83,5 +83,6 @@ void timer_init(void);
int gpio(uint8_t port, uint8_t data, uint8_t dir, uint8_t mask, uint8_t *res);
void board_init(void);
void board_app_init(void);
#endif /* !BOARD_H */

View File

@ -11,6 +11,7 @@
*/
#include <stddef.h>
#include <stdint.h>
#include <avr/io.h>
@ -19,6 +20,8 @@
#define F_CPU 8000000UL
#include <util/delay.h>
#include "usb.h"
#include "at86rf230.h"
#include "board.h"
#include "spi.h"
@ -131,3 +134,25 @@ int gpio(uint8_t port, uint8_t data, uint8_t dir, uint8_t mask, uint8_t *res)
return 1;
}
ISR(INT0_vect)
{
static uint8_t irq;
if (eps[1].state != EP_IDLE)
return;
spi_begin();
spi_send(AT86RF230_REG_READ | REG_IRQ_STATUS);
irq = spi_recv();
spi_end();
usb_send(&eps[1], &irq, 1, NULL, NULL);
}
void board_app_init(void)
{
/* enable INT0, trigger on rising edge */
EICRA = 1 << ISC01 | 1 << ISC00;
EIMSK = 1;
}

View File

@ -56,7 +56,7 @@ const uint8_t config_descriptor[] = {
#if 0
LE(9+9+7+7), /* wTotalLength */
#else
LE(9+9+9), /* wTotalLength */
LE(9+9+7+9), /* wTotalLength */
#endif
2, /* bNumInterfaces */
1, /* bConfigurationValue (> 0 !) */
@ -70,11 +70,7 @@ const uint8_t config_descriptor[] = {
USB_DT_INTERFACE, /* bDescriptorType */
0, /* bInterfaceNumber */
0, /* bAlternateSetting */
#if 0
2, /* bNumEndpoints */
#else
0,
#endif
1, /* bNumEndpoints */
USB_CLASS_VENDOR_SPEC, /* bInterfaceClass */
0, /* bInterfaceSubClass */
0, /* bInterfaceProtocol */
@ -89,7 +85,9 @@ const uint8_t config_descriptor[] = {
0x02, /* bmAttributes (bulk) */
LE(EP1_SIZE), /* wMaxPacketSize */
0, /* bInterval */
#endif
#if 1
/* EP IN */
7, /* bLength */