[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r5159 - in gnuradio/branches/developers/eb/fx2/usrp/fi
From: |
eb |
Subject: |
[Commit-gnuradio] r5159 - in gnuradio/branches/developers/eb/fx2/usrp/firmware: include lib src/usrp2 |
Date: |
Fri, 27 Apr 2007 14:37:56 -0600 (MDT) |
Author: eb
Date: 2007-04-27 14:37:55 -0600 (Fri, 27 Apr 2007)
New Revision: 5159
Modified:
gnuradio/branches/developers/eb/fx2/usrp/firmware/include/fx2utils.h
gnuradio/branches/developers/eb/fx2/usrp/firmware/include/usb_common.h
gnuradio/branches/developers/eb/fx2/usrp/firmware/lib/fx2utils.c
gnuradio/branches/developers/eb/fx2/usrp/firmware/lib/usb_common.c
gnuradio/branches/developers/eb/fx2/usrp/firmware/src/usrp2/usrp_main.c
Log:
work-in-progress on FX2 power mgmt problem
Modified: gnuradio/branches/developers/eb/fx2/usrp/firmware/include/fx2utils.h
===================================================================
--- gnuradio/branches/developers/eb/fx2/usrp/firmware/include/fx2utils.h
2007-04-27 20:30:46 UTC (rev 5158)
+++ gnuradio/branches/developers/eb/fx2/usrp/firmware/include/fx2utils.h
2007-04-27 20:37:55 UTC (rev 5159)
@@ -25,7 +25,7 @@
void fx2_stall_ep0 (void);
void fx2_reset_data_toggle (unsigned char ep);
void fx2_renumerate (void);
+void fx2_idle (void);
-
#endif /* _FX2UTILS_H_ */
Modified: gnuradio/branches/developers/eb/fx2/usrp/firmware/include/usb_common.h
===================================================================
--- gnuradio/branches/developers/eb/fx2/usrp/firmware/include/usb_common.h
2007-04-27 20:30:46 UTC (rev 5158)
+++ gnuradio/branches/developers/eb/fx2/usrp/firmware/include/usb_common.h
2007-04-27 20:37:55 UTC (rev 5159)
@@ -24,6 +24,8 @@
#define _USB_COMMON_H_
extern volatile bit _usb_got_SUDAV;
+extern volatile bit _usb_got_SUSPEND;
+extern volatile bit _usb_got_RESUME;
// Provided by user application to handle VENDOR commands.
// returns non-zero if it handled the command.
@@ -31,7 +33,9 @@
void usb_install_handlers (void);
void usb_handle_setup_packet (void);
+void usb_handle_suspend (void);
#define usb_setup_packet_avail() _usb_got_SUDAV
+#define usb_rqstd_suspend() _usb_got_SUSPEND
#endif /* _USB_COMMON_H_ */
Modified: gnuradio/branches/developers/eb/fx2/usrp/firmware/lib/fx2utils.c
===================================================================
--- gnuradio/branches/developers/eb/fx2/usrp/firmware/lib/fx2utils.c
2007-04-27 20:30:46 UTC (rev 5158)
+++ gnuradio/branches/developers/eb/fx2/usrp/firmware/lib/fx2utils.c
2007-04-27 20:37:55 UTC (rev 5159)
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2003 Free Software Foundation, Inc.
+ * Copyright 2003,2007 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -52,3 +52,26 @@
USBCS &= ~bmDISCON; // reconnect USB
}
+
+void
+fx2_idle (void)
+{
+ _asm
+ mov dptr,#_WAKEUPCS ; clear WU2 and WU bits in
+ movx a,@dptr ; the WAKEUPCS register
+ orl a,#0xC0
+ movx @dptr,a
+
+ mov dptr,#_SUSPEND ; write any value to SUSPEND reg
+ movx @dptr,a
+
+ orl PCON,#0x01 ; power down processor
+
+ nop ; ensure that processor suspends and resumes
+ nop ; before return
+ nop
+ nop
+ nop
+ ret
+ _endasm;
+}
Modified: gnuradio/branches/developers/eb/fx2/usrp/firmware/lib/usb_common.c
===================================================================
--- gnuradio/branches/developers/eb/fx2/usrp/firmware/lib/usb_common.c
2007-04-27 20:30:46 UTC (rev 5158)
+++ gnuradio/branches/developers/eb/fx2/usrp/firmware/lib/usb_common.c
2007-04-27 20:37:55 UTC (rev 5159)
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2003 Free Software Foundation, Inc.
+ * Copyright 2003,2007 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -35,7 +35,6 @@
extern xdata char str4[];
extern xdata char str5[];
-
#define bRequestType SETUPDAT[0]
#define bRequest SETUPDAT[1]
#define wValueL SETUPDAT[2]
@@ -49,6 +48,8 @@
#define LSB(x) (((unsigned short) x) & 0xff)
volatile bit _usb_got_SUDAV;
+volatile bit _usb_got_SUSPEND;
+volatile bit _usb_got_RESUME;
unsigned char _usb_config = 0;
unsigned char _usb_alt_setting = 0; // FIXME really 1/interface
@@ -58,6 +59,9 @@
xdata unsigned char *current_config_descr;
xdata unsigned char *other_config_descr;
+extern void user_enter_suspend(void);
+extern void user_leave_suspend(void);
+
static void
setup_descriptors (void)
{
@@ -101,6 +105,21 @@
setup_descriptors ();
}
+static void
+isr_SUSPEND (void) interrupt
+{
+ clear_usb_irq ();
+ _usb_got_SUSPEND = 1;
+}
+
+static void
+isr_RESUME (void) interrupt
+{
+ RESI = 0; // clear the RESUME irq request flag
+ _usb_got_RESUME = 1;
+}
+
+
void
usb_install_handlers (void)
{
@@ -109,8 +128,15 @@
hook_uv (UV_SUDAV, (unsigned short) isr_SUDAV);
hook_uv (UV_USBRESET, (unsigned short) isr_USBRESET);
hook_uv (UV_HIGHSPEED, (unsigned short) isr_HIGHSPEED);
+ hook_uv (UV_SUSPEND, (unsigned short) isr_SUSPEND);
- USBIE = bmSUDAV | bmURES | bmHSGRANT;
+ USBIE = bmSUDAV | bmURES | bmHSGRANT | bmSUSP;
+
+ // hook_sv (SV_RESUME, (unsigned short) isr_RESUME);
+
+ // mbWU2| mbWU2 clear possible interrupt requests
+ WAKEUPCS = bmWU2 | bmWU | bmDPEN; // we wakeup only on USB activity
+ // ERESI = 1; // enable RESUME interrupt
}
// On the FX2 the only plausible endpoints are 0, 1, 2, 4, 6, 8
@@ -383,3 +409,20 @@
// ack handshake phase of device request
EP0CS |= bmHSNAK;
}
+
+void
+usb_handle_suspend (void)
+{
+ _usb_got_SUSPEND = 0;
+
+ user_enter_suspend();
+
+ fx2_idle (); // FIXME put FX2 in idle state
+
+ //while (!_usb_got_RESUME)
+ // ; // nop
+
+ _usb_got_RESUME = 0;
+
+ user_leave_suspend();
+}
Modified:
gnuradio/branches/developers/eb/fx2/usrp/firmware/src/usrp2/usrp_main.c
===================================================================
--- gnuradio/branches/developers/eb/fx2/usrp/firmware/src/usrp2/usrp_main.c
2007-04-27 20:30:46 UTC (rev 5158)
+++ gnuradio/branches/developers/eb/fx2/usrp/firmware/src/usrp2/usrp_main.c
2007-04-27 20:37:55 UTC (rev 5159)
@@ -227,6 +227,8 @@
if (usb_setup_packet_avail ())
usb_handle_setup_packet ();
+ if (usb_rqstd_suspend ())
+ usb_handle_suspend ();
if (GPIFTRIG & bmGPIF_IDLE){
@@ -345,13 +347,6 @@
void
main (void)
{
-#if 0
- g_rx_enable = 0; // FIXME (work around initialization bug)
- g_tx_enable = 0;
- g_rx_overrun = 0;
- g_tx_underrun = 0;
-#endif
-
memset (hash1, 0, USRP_HASH_SIZE); // zero fpga bitstream hash. This
forces reload
init_usrp ();
@@ -378,3 +373,17 @@
main_loop ();
}
+
+void
+user_enter_suspend(void)
+{
+ set_led_0(1);
+ set_led_1(1);
+}
+
+void
+user_leave_suspend(void)
+{
+ set_led_0(0);
+ set_led_1(0);
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r5159 - in gnuradio/branches/developers/eb/fx2/usrp/firmware: include lib src/usrp2,
eb <=