Author: ks156
Date: 2009-10-20 08:36:56 +0200 (Tue, 20 Oct 2009)
New Revision: 5745

Modified:
   firmware/tuxaudio/branches/auto_reset_rf/main.c
Log:
* Reset the RF each second when the RF connexion is lost.


Modified: firmware/tuxaudio/branches/auto_reset_rf/main.c
===================================================================
--- firmware/tuxaudio/branches/auto_reset_rf/main.c     2009-10-20 06:35:28 UTC 
(rev 5744)
+++ firmware/tuxaudio/branches/auto_reset_rf/main.c     2009-10-20 06:36:56 UTC 
(rev 5745)
@@ -91,6 +91,32 @@
      * interrupt vector initialized will loop infinitely. */
 }
 
+
+volatile uint8_t rf_counter = 0;
+void monitor_rf(void)
+{
+    if (rf_counter > 30)
+    {
+       rf_counter = 0;
+       
+       /* Deconnection detected : Reset the RF ! */
+       if (!(RF_ONLINE_PIN & RF_ONLINE_MK))
+       {
+           uint16_t i = 0;
+       
+           /* Active the reset */
+           PORTB &= ~_BV(PB7);
+    
+           /* Keep the state for a while (1/8MHz * 4000) ~ 500us */
+           while (i < 4000)
+               i++;
+    
+           /* Restart the RF */
+           PORTB |= _BV(PB7);
+       } 
+    }
+}
+
 void sleep(void)
 {
     uint8_t PRR_bak;
@@ -255,6 +281,7 @@
     {
         sei(); /* XXX can we remove this? */
 
+       monitor_rf();
         /* Check for stack overflow. */
         if (!check_stack())
             while(1)
@@ -307,6 +334,7 @@
  * ISR each 256*1024/8e6 = 33ms */
 ISR(SIG_OVERFLOW2)
 {
+    rf_counter++;
     send_sensors_flag = true;
 }
 


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to